Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/395.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将变量添加到';类名';在jquery中使用匹配函数?_Javascript_Jquery_Regex - Fatal编程技术网

Javascript 如何将变量添加到';类名';在jquery中使用匹配函数?

Javascript 如何将变量添加到';类名';在jquery中使用匹配函数?,javascript,jquery,regex,Javascript,Jquery,Regex,我想使用jquery中的match函数检查具有模式的类名,例如sort-order12、sort-order13。 以下用法不起作用。有人能帮忙吗 var sort_order = $('.js-data-selector.active:first').data('sort-order'); sort\u order\u next->是包含整数值的变量 var child = $("table tr td").filter(function() { return $(this).prop(

我想使用jquery中的match函数检查具有模式的类名,例如sort-order12、sort-order13。 以下用法不起作用。有人能帮忙吗

var sort_order = $('.js-data-selector.active:first').data('sort-order');
sort\u order\u next->是包含整数值的变量

var child = $("table tr td").filter(function() {
  return $(this).prop("class").match(/"sort-order"+(sort_order_next)/)
}).closest("tr");

child.show();
我试图根据获得的节点值(下一个排序顺序)显示具有模式“sort-order-1”、“sort-order-2”等类名的节点

试试这个

var sort\u order\u next=12;
var child=$(“表tr td”).filter(函数(){
返回$(this.prop(“class”).match(新的RegExp('sort-order-'+sort\u order\u next));
}).最近的(“tr”);
console.log(子级)

此代码有效!!谢谢你的帮助,亚历山大!