[英]How do I pass a searchstring to perform a search?
again I'm stuck and asking you to help me. 我再次陷入困境,并要求您帮助我。
I want to enter a search string in an input-field. 我想在输入字段中输入搜索字符串。 The search string should perform a search like https://.../=~searchstring
搜索字符串应执行类似于https://.../=~searchstring的搜索
The textfield: 文字栏位:
$("<input id='field-inputSearchString' type='text' name='field_inputSearchString'>").insertAfter('.completed ticket');
I've got two questions here: 我在这里有两个问题:
I guess I need to 'find' the string to pass it to the search link. 我想我需要“找到”字符串以将其传递给搜索链接。 Is it sth.
是不是…… like this?
像这样?
$(function() { var foundin = $('input[id$='field-inputSearchString']:contains(text)'); });
And how do I pass the text to the link? 以及如何将文本传递给链接? Have you got an example or link explaining what I'm looking for?
你有一个例子或链接解释我在找什么吗?
I appreciate every help. 感谢您的帮助。 Thank you so much in advance.
提前非常感谢您。
To get the value of an input field with id you can do 要获取具有ID的输入字段的值,您可以执行以下操作
$("#field-inputSearchString").val();
You cannot use :contains
because it searches for elements that contains the text. 您不能使用
:contains
因为它会搜索包含文本的元素。
If you want to pass the string to the href of an anchor tag 如果要将字符串传递到锚标记的href
var href = $("#anchorID").attr("href");
$("#anchorID").attr("href", href + $("#field-inputSearchString").val());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.