Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery: $(document).on(event, name as selector, function [duplicate]

Sorry if this is too simple, I am new to programming and I stumbled upon this problem. How can I use the name attribute as the selector inside a
$(document).on('click', '#thisisforid', function().. ?

It is well documented that I can use the id and class name by using #idname and .classname but it is nowhere to be found (I tried so hard to search) how to or if I could use the name attribute instead.

like image 746
super-user Avatar asked Feb 06 '17 14:02

super-user


1 Answers

Use an Atrribute Selector like this:

$("[name = 'theNameYouWant']");

More CSS Selectors here.

Note: The CSS Selectors are not exclusive features of jQuery. They work everywhere (in CSS files, using document.querySelector ...)

like image 129
ibrahim mahrir Avatar answered Oct 09 '22 04:10

ibrahim mahrir