English 中文(简体)
que
原标题:Jquery contains selector, regex

This is my code:
Let s say that name is set to john

$("#first_table").append($( #second_table ).find("tr:contains(" + name + ")"));

基本上,我在网站上有2个表格。 我想首先把内容移至第二,但只有完全匹配。 如何做到这一点?

Now if I have (for example) john john #1, john #2 in my table, they would all be moved. I would only like to move john and leave john #1 and john #2 Thanks! EDIT: I would like the code to work to match the variable name EXACTLY. So if name is JOHN it must only get JOHN. If it s JOHN #1, it must only get JOHN #1 and so on. Is this possible?

最佳回答

由于每一名名字均可上<代码>:内容(+名称+”),该词与所有这些内容一致。

采用<代码>:将“#”删除。

$("#first_table").append($( #second_table ).find("tr:contains(" + name + "):not(:contains( # ))"));

最新情况:

如果你想要准确了解内部的价值观。 然后使用类似的东西。

$("#second_table tr td").each(function() {
   if($(this).text() ==  John ) { 
     $(this).closest("tr").appendto($("#first_table")); //find the cotaining tr and append to another table
   }
});
问题回答

这可能是一例缺失的引述。 如下文所示,在<代码>上添加单一报价。

$("#first_table").append($( #second_table ).find("tr:contains( " + name + " )"));




相关问题
Uncommon regular expressions [closed]

Recently I discovered two amazing regular expression features: ?: and ?!. I was curious of other neat regex features. So maybe you would like to share some tricky regular expressions.

regex to trap img tag, both versions

I need to remove image tags from text, so both versions of the tag: <img src="" ... ></img> <img src="" ... />

C++, Boost regex, replace value function of matched value?

Specifically, I have an array of strings called val, and want to replace all instances of "%{n}%" in the input with val[n]. More generally, I want the replace value to be a function of the match ...

PowerShell -match operator and multiple groups

I have the following log entry that I am processing in PowerShell I m trying to extract all the activity names and durations using the -match operator but I am only getting one match group back. I m ...

Is it possible to negate a regular expression search?

I m building a lexical analysis engine in c#. For the most part it is done and works quite well. One of the features of my lexer is that it allows any user to input their own regular expressions. This ...

regex for four-digit numbers (or "default")

I need a regex for four-digit numbers separated by comma ("default" can also be a value). Examples: 6755 3452,8767,9865,8766,3454 7678,9876 1234,9867,6876,9865 default Note: "default" ...

热门标签