jQuery .click没有运行
你好堆叠器
我遇到了点击操作的问题。 它只是不起作用,它不运行Click。 单击时,它什么都不做。 甚至没有返回错误。 点击错了吗?
$( document ).ready(function() { console.log("notclicked"); $("#makesee-").click(function() { console.log("clickerdeclick"); $.ajax({ type: "POST", url: "seenot.php", async: true, data: { a: , b:}, success: function(result){ console.log(result); console.log("twerkt"); }, error: function (response) { //if error output data in console console.log(response); console.log("lol"); } }); }); });
这是我的按钮,
<a class="btn btn-default" id="#makeseen-">
修复ID attribut以使其中没有PHP代码。
做这样的事情(如果你需要PHP的ID:
然后你使用这个jQuery:
$(".myButton").on("click", function() { var id = $(this).data("id"); $.ajax({ type: "POST", url: "seenot.php", async: true, data: {"a": id }, ... etc ... }); });
避免混用PHP和Javascript。
按键
jQuery的
$(document).ready(function() { $("button").click(function() { alert($(this).children("a").data("id")); }); });
小提琴
小提琴