我的问题是关于:
我想在输入click时触发此功能
$('.s-link').click(function()
{
var x = "/search/node?keys=";
var y = $('.i-search').val();
var result = x + y;
$('a').attr('href', result);
});
答案 0 :(得分:1)
您可以将代码放在onclick内
$(document).keypress(function(e) {
if(e.which == 13) {
alert('You pressed enter!');
var x = "/search/node?keys=";
var y = $('.i-search').val();
var result = x + y;
$('a').attr('href', result);
}
});
答案 1 :(得分:1)
$('#someTextBox').keypress(function(event){
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){
var x = "/search/node?keys=";
var y = $('.i-search').val();
var result = x + y;
$('a').attr('href', result);
}
});
尝试此操作并根据您的程序更改#someTextBox