JQuery find element by value of its name? (Name = Value)

I know how to find an object .classnameand elementname, and I think that #idname, but how can I find out its meaning?

+3
source share
3 answers

You can find elements by attribute value with

$('element[attribute="value"]')

where elementis an arbitrary selector ( HTML element, .classnameor #ID) and attributecan be any attribute that you put in tags, for example. srcfor elements imgor hreffor elements aor also namefor form field elements.

for example

$('#ID')

can be rewritten as (assuming the element is div):

$('div[id="ID"]')

, , , , , .

+6
$('elementname[name=foo]')

docs

+4

:

$('element[attr=val');

So for a table called "MyTable"

$('table[name=MyTable]');

Of course, this does not just apply to the elements:

$('.MyClass[name=MyTable]');
+4
source

Source: https://habr.com/ru/post/1732493/


All Articles