i’m kinda of a newbie in javascript, even though i built so far lots of working website and apps..
btu i feel naive the way i used to pass the variable id to jquery..
for instance i used to do like this epsecialy when i have to work with some old code
..
let’s assume that i have all my website already coded with ‘a’ tags like this
<a id='myId' onclick='doSome(this.id)' > link </a>
and then in JS
function doSome(id){
//old code removed and replaced by jquery
jQuery("#"+ id).show();
}
and the function in that way works flawless…
so, again, assuming that i cannot change anything else than the code inside the function what’s the best way to use the variable id?
because as far as i know if I had used just
jQuery(id).show();
instead of
jQuery("#"+ id).show();
it wouldn’t have worked…right?
Instead of passing
this.id, passthisThen you can call the function like: