开发者

Using Jquery variable in Javascript

开发者 https://www.devze.com 2023-04-11 20:05 出处:网络
I am using jQuery selector in an AJAX request call , so according to the value returned by request , I select the required div using :eq() selector, but the problem is that I am stuck with some undefi

I am using jQuery selector in an AJAX request call , so according to the value returned by request , I select the required div using :eq() selector, but the problem is that I am stuck with some undefined stuffs

Here is what I wish to do

$('.win7red:eq(9)').parent.children('span:eq(1)').children('div:first').css("opacity", "1");

Here the value in first eq selector has to be variable as per the request

I obtained the value in a javascript variable called req and then I used this, but it shows ERROR

$('.win7red:eq(req)').parent.children('span:eq开发者_开发问答(1)').children('div:first').css("opacity", "1");

I even tried this, but none of them worked

$var = $('.win7red');
$var1 = $var:eq(req); 
$var1.parent.children('span:eq(1)').children('div:first').css("opacity", "1");

Please help in solving this problem.


Use parent() as a function instead of a property.

So, $('.win7red:eq(9)').parent( ) ...

Using .parent without parentheses can only be used at DOM objects, such as $("body").get(0).parentNode (=$("body").parent()).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号