我收到了一個意外的錯誤,其中有一個令人討厭的時間調試。 我得到的錯誤是這樣的:爲什麼我無法將jQuery選擇器對象從內聯HTML元素傳遞給函數?
Uncaught SyntaxError: Unexpected token }
這是HTML:
<html>
<head>
<script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>
<body>
<form class="search" action="search" method="get">
<input type="text" id="search-string" />
<button type="button" onclick="return clearInputValue($("#search-string"))">
<span class="clear-icon"></span>
</button>
</form>
<script>
var clearInputValue = function(a) {
// Ultimately I will check if the object passed to this function has a value greater than 1, and if so, I will clear the input
return false;
};
</script>
</body>
</html>