The jQuery .on()
function was introduced in jQuery version 1.7.
Instead of using the .click()
function, which was added in jQuery version 1.0, consider utilizing it. Do note that prior to version 1.4.3, eventData cannot be specified with this function.
For events other than click, there are equivalent functions available from version 1.0 onwards:
$("span.cls").click(function(){
$("#dialog").html("");
});
span{
border: 1px solid;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<span class="cls">remove content below</span>
<div id="dialog"><p>something</p></div>
You also have the option to utilize the .live()
generic event binder, where you specify the event type as a string similar to the .on()
function. While the .live()
function has been deprecated in favor of .on()
in jQuery version 1.7, for older versions like the one you are using, it is still suitable.
$("span.cls").live("click", function(){
$("#dialog").html("");
});
span{
border: 1px solid;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js></script>
<span class="cls">remove content below</span>
<div id="dialog"><p>something</p></div>