简体   繁体   English

如何传递搜索字符串以执行搜索?

[英]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: 我在这里有两个问题:

  1. 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)'); }); 

  2. 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.

相关问题 如何在 jquery 中执行 div 搜索? - How do I perform a div search in jquery? 如何使用Winforms Cefsharp执行Google Map搜索 - How do I perform a Google Map search with Winforms cefsharp HTML文本框作为tr中的数据。 输入搜索字符串后,如何对此类表执行动态搜索操作? - HTML Textboxes as data in tr. How do I perform dynamic search operation for such table on input of search string? 如何将超链接传递到Carrot Search FoamTree中? - How do I pass hyperlinks into Carrot Search FoamTree? 我如何将变量传递给 Nedb 的搜索查询 - how do i pass a variable into search query of Nedb 如何使用Imgur API将参数传递到图库搜索中 - How do I pass parameters into a gallery search using the Imgur API 如何将变量从一页上的输入框传递到另一页上,并使用此信息在第2页上执行搜索? - how can I pass a variable from an input box on one page to another page and use this info to perform a search on page 2? 如何延迟执行foreach以执行搜索和替换功能。 有延迟 - How to do a foreach with delay to perform a search and replace function. WITH DELAY 如何在 Angular 2 中执行无限动画? - How do I perform infinite animations in Angular 2? 如何执行顺序的ajax调用? - How do I perform sequential ajax calls?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM