为什么 Jquery tokeninput 值为空?
Why Jquery tokeninput value is null?
我用过http://loopj.com/jquery-tokeninput/分词器。数组值始终为空。这是我的代码。任何人都可以告诉我的代码有什么问题吗?
<div>
<input type="text" id="first" name="first" onchange="callthis()"/>
<script type="text/javascript">
$(document).ready(function() {
$("#first").tokenInput([
{name: "Ruby"},
{name: "Python"},
{name: "JavaScript"},
{name: "ActionScript"},
{name: "Scheme"},
{name: "Lisap"},
{name: "C#a"},
{name: "Fortran"},
{name: "Visual Basic"},
{name: "Ca"},
{name: "C++"},
{name: "Java"}
]);
});
</script>
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="src/jquery.tokeninput.js"></script>
<link rel="stylesheet" href="styles/token-input.css" type="text/css" />
<script>
function callthis(){
var val = $('#first').tokenInput("get");
alert(val);
}
</script>
在他们的文档中,他们要求使用这一行来获取值。selector.tokenInput("get");
提前致谢。
我刚刚尝试使用以下代码:
$("#first").tokenInput([
{name: "Ruby"},
{name: "Python"},
{name: "JavaScript"},
{name: "ActionScript"},
{name: "Scheme"},
{name: "Lisap"},
{name: "C#a"},
{name: "Fortran"},
{name: "Visual Basic"},
{name: "Ca"},
{name: "C++"},
{name: "Java"}
]);
$("#first").change(function(){
var val = $('#first').tokenInput("get");
});
它工作正常。请参阅此示例 http://jsfiddle.net/L4oth1d8/3/
我用过http://loopj.com/jquery-tokeninput/分词器。数组值始终为空。这是我的代码。任何人都可以告诉我的代码有什么问题吗?
<div>
<input type="text" id="first" name="first" onchange="callthis()"/>
<script type="text/javascript">
$(document).ready(function() {
$("#first").tokenInput([
{name: "Ruby"},
{name: "Python"},
{name: "JavaScript"},
{name: "ActionScript"},
{name: "Scheme"},
{name: "Lisap"},
{name: "C#a"},
{name: "Fortran"},
{name: "Visual Basic"},
{name: "Ca"},
{name: "C++"},
{name: "Java"}
]);
});
</script>
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="src/jquery.tokeninput.js"></script>
<link rel="stylesheet" href="styles/token-input.css" type="text/css" />
<script>
function callthis(){
var val = $('#first').tokenInput("get");
alert(val);
}
</script>
在他们的文档中,他们要求使用这一行来获取值。selector.tokenInput("get");
提前致谢。
我刚刚尝试使用以下代码:
$("#first").tokenInput([
{name: "Ruby"},
{name: "Python"},
{name: "JavaScript"},
{name: "ActionScript"},
{name: "Scheme"},
{name: "Lisap"},
{name: "C#a"},
{name: "Fortran"},
{name: "Visual Basic"},
{name: "Ca"},
{name: "C++"},
{name: "Java"}
]);
$("#first").change(function(){
var val = $('#first').tokenInput("get");
});
它工作正常。请参阅此示例 http://jsfiddle.net/L4oth1d8/3/