Jquery Find Element In Ul Li Span
I have an HTML structure as:
Solution 1:
Here's a fairly simple and straightforward answer:
// gets all anchors with attribute rel and place their [seq] values into an arrayvar values = $.map($('a[rel]'), function(el){
return el.getAttribute('seq');
});
console.log(values); // ["1", "2"]
Solution 2:
var seq = $("a[rel]").attr("seq");
Solution 3:
Try this:
var anchor = $('a[rel][seq]'); // this only targets anchors which have these // rel and seq attributes.
You can try this:
$('a[rel][seq]').on('click', function () {
alert($(this).attr('seq'));
});
Fiddle
Solution 4:
You can use next selector for specific rel
value
var seq3 = $("a[rel='3']").attr("seq");
To get sum of all sequences use next:
var sum = 0;
$.each($("a[rel='3']"), function(i, el)
{
sum += el.getAttribute("seq") | 0
})
Solution 5:
jQuery(document).ready(function(){{
var check=jQuery(".search-choice a ").attr("rel");
if(check!="undefined")
{
var selVar=jQuery(this).attr("seq");
}
})
you should write a script like this, you can also store all "seq" value in an array.
Post a Comment for "Jquery Find Element In Ul Li Span"