I am trying to change my last name once the button was click.
I am currently using jQuery.data to do this. Although I understand that these can be done using other form but I need to use jQuery.data here for my application.
Here's my markup code so far:
<div id="container">
My complete name is <span></span> D. <span></span>
</div>
<button type="button" id="btnID" onclick="changebtn()">Set Last Name to Smith </button>
Here's my jQuery codes:
var holder = $( "#container" )[0];
jQuery.data( holder, "data", {
firstname: "Sam",
lastname: "Norton"
});
$( "span:first" ).text( jQuery.data( holder, "data" ).firstname );
$( "span:last" ).text( jQuery.data( holder, "data" ).lastname );
function changebtn(){
}
Here's my jSFIDDLE: http://jsfiddle.net/vzzscnmr/1/
Any ideas?
NOTE: We need to use jQuery.data specifically on this part NOT A SIMPLE JQUERY SOLUTION.
.data()method?