I have the following code:
$(document).ready(function(){
$("button.continue").click(function(){
$(this).html("Hello!");
});
});
Which works perfect but I want to turn the whole thing into something like this:
$(document).ready(function(){
$("button.continue").click().html("Hello!");
});
My questions are:
- Can I use click() and a following event, in this case html() in that way (Without turning to the function part)?
- If not, why can I not do this since I would think of the workings behind this, something like: When user clicks on the element selected, change the HTML text in it to something else.
- If this is not the way to think or reason the logic behind this, how should I approach this
.click()with no arguments is a shorthand for.trigger('click').