如何使用$(this)在条件中重用特定选择器

时间:2015-05-16 02:11:08

标签: jquery jquery-selectors this

如果$(this)的特定实例等于条件中的特定值,我如何使用$('select').data('field')重用if ($('select').data('field') === "DriverDiscovery.AddStatus") { alert( $(this) ); } 的特定实例。

    // obtain tasks names
    List<String> runTasks = gradle.startParameter.getTaskNames();

    for (String item : runTasks)
        // increment only version on task which contains word assemble & Release
        if (item.contains('assemble') && item.contains('Release')) {
            value = 1;    // <- u can use here  "item.mustRunAfter clean"
        }

由于

1 个答案:

答案 0 :(得分:0)

这个怎么样:

$('select').each(function(){//for each select element
     if($(this).data('field') == "DriverDiscovery.AddStatus"){//if the condition is met
          alert($(this).text());//print its text
     }
})