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
精彩评论