Classic javascript:
var myvar = document.getElementById("abc");
abc.value += "test";
abc.value += "another test";
Jquery:
$("#abc").val($("#abc").val()+"test");
$("#abc").val($("#abc").val()+"another test");
Is there a way to make my Jquery prettier, maybe with a hidden += function that I could use? I know that .val() is not an attribute, but I feel there must be a way to make this code more beautiful to look at...
Something like this would be great:
$("#abc").valueAttribute += "test"
$("#abc").val().content += "test"
$("#abc").val().add("test")
.value
(including the first part of my answer). It will only work for<input>
elements. You may end up pulling your hair out one day if abc becomes a<textarea>
.