提问者:小点点

如何对不同的值使用两个jQuery匹配函数?


为不同的值放置两个jQuery匹配函数有点混乱

这里我有一个密码

 $(".example").each(function() {
    var v = $(this),
        a = $(this).find("span").attr("data-label"),
        b = $(this).find("span").attr("data-no"),
        e = $(this).find("span").attr("data-type");
    null != e && e.match("recent") && $.ajax({
      url: "/feeds/posts/summary?alt=json&max-results=5" + b,
        type: "get",
        dataType: "jsonp",
        beforeSend: function() { 

直到秀。。。。。。。。。。。。。。。。。

最近是数据类型,所以我尝试为不同的url实现一个更多的匹配函数,但未能设置这里的任何人,有什么想法设置这个吗?

这是第二个代码

null != e && e.match("bgrid") && $.ajax({
       url: "/feeds/posts/default/-/" + a + "?alt=json-in-script&max-results=" + b,
        type: "get",
        dataType: "jsonp",
        beforeSend: function() {

秀。。。。。。。安

这里,bgrid是我的第二个匹配函数,我已经尝试实现了,但现在是方法或解决方案

如果这里的任何开发人员在堆栈溢出有任何类型的想法或解决方案来实现这个匹配功能(上面的代码用于blogger平台的自定义特色帖子),当我结合这些代码由esle如果标签,它是不工作的! 谢谢你


共1个答案

匿名用户

$(".example").each(function() {
  var v = $(this),
      a = $(this).find("span").attr("data-label"),
      b = $(this).find("span").attr("data-no"),
      e = $(this).find("span").attr("data-type");

  if(null != e && e.match("recent")) {
    $.ajax({
      url: "/feeds/posts/summary?alt=json&max-results=5" + b,
      type: "get",
      dataType: "jsonp",
      beforeSend: function() { 
        // ...
      }
    });
  } else if (null != e && e.match("bgrid")){
    $.ajax({
      url: "/feeds/posts/default/-/" + a + "?alt=json-in-script&max-results=" + b,
      type: "get",
      dataType: "jsonp",
      beforeSend: function() {
        // ...
      }
    });
  } else {
    // else ..
  }
});
``