It seems like there should be a better way to code this:
HTML snippet:
<label onclick="addstuff(this)" id="label_id">Hello</label>
JS/jQuery snippet:
function addstuff(field){
$('#'+field.id).before('<div>Just a random element being added…</div>');
}
I dislike that I am referencing my field in the Javascript by $('#'+field.id) when the field is already being passed in. It seems like there should be another way to reference field in jQuery using the field object that is passed in, which in my mind should be more efficient, but I'm not having any luck figuring it out. Any advice is greatly appreciated.