How do you get id in div?
<div id="container"> <div id="frag-123">ass</div> <div id="frag-123">ass</div> <div id="frag-123">ass</div> </div>
Thanks!
There are several ways to do this. You can use map():
map()
var ids = $("#container").children().map(function(n, i) { return n.id; });
or each():
each()
$("#container").children().each(function(n, i) { var id = this.id; // do something with it });
etc.
you can use
attr('id')
$('div', $('div#container')).each(function() { console.log($(this).attr('id')); });
to get them as an array of strings
var ids = $.map($('#container div'), function(n,i) { return n.id });
Source: https://habr.com/ru/post/1718160/More articles:Do robots scan iframes? - iframeКниги и учебные пособия по службам Windows на С#? - windows-servicesSql Server Configuration Advisor Report - performanceWebBrowser control: how to suppress a message: you want to close this window - c #image magick: right alignment in area - scriptingC #, LINQ, SQL: composite columns - c #how to pass an array string [] to a web service via jQuery? - jqueryHow to filter empty fields in Jira? - jirahow to add (or ignore) the XML namespace when using XElement.Load - c #How to determine if a variable's value is a symbol associated with a procedure in a Schema? - functional-programmingAll Articles