gpt4 book ai didi

javascript - jQuery 函数获取对象

转载 作者:行者123 更新时间:2023-11-28 12:06:48 25 4
gpt4 key购买 nike

我想更改这个旧的 JavaScript 函数

function getObj(x) {
this.obj = document.getElementById(x);
this.style = document.getElementById(x).style;
}

通过另一个使用 jQuery 的函数。像这样的事情:

function getObj(x) {
this.obj = $(x.obj);
this.style = $(x.obj).style;
}

当然,这个不起作用。

最佳答案

使用这个

function get(x){
var x = $('#'+x);
}

http://jsfiddle.net/eCZZn/

关于javascript - jQuery 函数获取对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8261237/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com