I want to select and change a div with my own attribute let say myAttribute=”1235″
I try this
<font myAttribute="1235">Change me !</font>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
var myAttribute = 1235;
$("[myAttribute='+myAttribute+']").html('is working');
$("[myAttribute='+myAttribute']").html('is working');
$("[myAttribute=''+myAttribute]").html('is working');
</script>
but they dont work !! if change the code to
$("[myAttribute='1235']").html('is working');
everthing is ok but i want to use a variable
You need an editor with highlighting 🙂
Add extra quotes to make it happen