So this is my example HTML:
<div name="John Doe"></div>
Note: I know all about ID’s and classes in CSS. I am fully aware they exist. But in this case I’m wondering what to do when it’s the name value I’m trying to work with.
Basically, how do I save the name of the div, in this case “John Doe” to a variable?
I can successfully access it with the below code:
$(document).ready(function(){
$('div[name="John Doe"]').click(function(){
Do something;
};
You should use
dataattributes for thisHTML:
JS:
http://jsfiddle.net/6tatB/