I know I can select elements using the following syntax, but what other ways are available? I didn’t know what to search for when trying to determine others. Also, are there ways to select elements via wildcard characters?
//Selection by the element's ID
$('#mybutton').on('click', function (e) {
alert('mybutton clicked');
});
//Select by the element's css class
$('.mybuttonclass').on('click', function (e) {
alert('mybutton clicked');
});
//Selection of a tag with name of delete found within a table
$('table').on('click','a[name=delete]', function (e) {
alert('table link clicked');
});
So, I can use name, ID or class. Are there other ways? A google search term or a link would be helpful.
EDIT:
I had found the selectors page in the documentation, but didn’t think this page applied. I had trouble making sense of the page, and thought that it was referring to something else. That’s why I was looking for another search term, because everything was bringing up ‘Selectors’, and I didn’t think that’s what I was needing. apparently I was in the right place after all.
1 Answer