12

I found many example finding elements by attribute value BUT not with name. I want to find all elements (can be link, button, anything) with the attribute containing deleteuserid. I tried this:

console.log($('[deleteuserid!=""]'));

but this find "everything" which not even containing the deleteuserid attribute...

something like this: jQuery how to find an element based on a data-attribute value? expect that I dont have a concrete value (in other words, I want to find $("ul").find("[data-slide=*]");

Community
  • 1
  • 1
John Smith
  • 6,129
  • 12
  • 68
  • 123

5 Answers5

17

Simply use deleteuserid instead of deleteuserid!="" like following.

console.log($('[deleteuserid]'));
Ibrahim Khan
  • 20,616
  • 7
  • 42
  • 55
6

you can use the jquery attribute selector to search by name.

console.log($('[name="deleteuserid"]'));
Avinash Jain
  • 7,200
  • 2
  • 26
  • 40
6

You can search by simple $('[name="deleteuserid"]')

console.log($('[name="deleteuserid"]'))
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p name="deleteuserid">

</p>
<div name="deleteuserid">

</div>
<i name="deleteuserid"></i>
<b></b>
Dhara
  • 1,914
  • 2
  • 18
  • 37
3
$( "*[name*='deleteuserid']" ).addClass('iFoundyou');

JSFiddle

Pedram
  • 15,766
  • 10
  • 44
  • 73
1

Reference: https://www.w3schools.com/cssref/sel_attr_begin.asp

My demo: All my selects have id="<f_field_name>"

    <select id="f_type" />
    <select id="f_employee" />
   $('[name="form_monitoria_ligacoes"]').find('[id^="f_"]')
Alex Alan Nunes
  • 174
  • 2
  • 9