How can I use the following code in an onclick event for a button other than a function():
{
$.ajax({
type:'GET',
url: 'noload.php?user-first=<?php print($user_name_first); ?>&user-send=<?php print($_GET['user']); ?>',
success: function(data){
$("#search-result").html(data);
}
});
}
你可以这样做
<input type="submit" onclick="function() { //your code }">
According to the HTML standard, onclick
and other event handler attributes contain JavaScript code.
See details here: http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#event-handler-content-attributes
Therefore, you can put your JavaScript code directly inside the onclick
attribute:
<button onclick=" /* JavaScript code here */ "> Button </button>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.