开发者

Jquery: is there another way to write this, maybe using .attr?

I thought I could re-write the line below:

$('a').filter('[ha开发者_如何学运维sh=' + inview + ']');

to something like this:

$('a').attr(href, inview);

obviously with var inview = yada yada yada defined above it.

or is there another way to write the first line up there,

using jquery and getting rid of the [hash=' for something like .attr or .something(inview)?


$('a[hash=' + inview + ']');

That should do it.


You want something like:

$('a[hash="' + inview + '"]')

$('a').attr('hash', inview);, which is what I assume you meant for your second line, actually sets the hash attribute to inview.


$('a').attr(href, inview);

For reference that would set the href of all a elements to inview

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜