Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.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
Jquery 需要获得';a';插件的每个.post的名称_Jquery_Loops_Plugins_Each - Fatal编程技术网

Jquery 需要获得';a';插件的每个.post的名称

Jquery 需要获得';a';插件的每个.post的名称,jquery,loops,plugins,each,Jquery,Loops,Plugins,Each,现在的情况是,它会出现这样的url- http://www.easybbtutorials.com/t177-user-profile-home-page#1244#undefined 所以我添加了split('#')[0]这很有效,但我仍然得到了未定义的部分 http://www.easybbtutorials.com/t177-user-profile-home-page#undefined 同样,在每个.post中,每个fb喜欢的都是相同的url,它需要添加每个家长一个名称 我可能不明白

现在的情况是,它会出现这样的url-

http://www.easybbtutorials.com/t177-user-profile-home-page#1244#undefined

所以我添加了
split('#')[0]这很有效,但我仍然得到了未定义的部分

http://www.easybbtutorials.com/t177-user-profile-home-page#undefined

同样,在每个
.post
中,每个fb喜欢的都是相同的url,它需要添加每个家长
一个
名称

我可能不明白我是怎么说的,但我现在很生气,而且写得很快

更好的解释:

  • .post是第一个,fb data href应该是
    http://www.easybbtutorials.com/t177-user-profile-home-page#8870
  • .post是第二个,fb data href应该是
    http://www.easybbtutorials.com/t177-user-profile-home-page#8871
  • .post是第三个,fb data href应该是
    http://www.easybbtutorials.com/t177-user-profile-home-page#8872
  • .post是第四个,fb data href应该是
    http://www.easybbtutorials.com/t177-user-profile-home-page#8873
  • 诸如此类,这是一个论坛,因此将有多个。张贴区

    到目前为止,我必须这样写电话……

    var url = window.location.href.split('#')[0];
    var post = $('.post').children('a[name]').attr('name');
    var helpers = {`
    
    我想插件自动做每件事真的。因此,
    $('.post').easyface()
    将自动执行上述代码

    我现在还需要它来获取
    ('a[name]').attr('name'),尽管我现在不得不这样添加,
    ('a[name]').attr('name').split('p')[1]因为所有id都以pEx开头:p830 p338 p395 p代表post。而且给定的链接无法识别#p784,所以它需要变成#784

    谁能得到这个工作可以有我所有的声誉,是设置在100。。。现在我只有43个,但不管怎么说,我等这个太久了

    这里有更好的理解:


    正如你所看到的,我有四个喜欢和发送,就像他们都喜欢的一样。每个帖子需要不同的url。

    第1期:

    $('.post').each(function() {
       $(this).easyface();
      });
    
    children()
    将返回元素列表

    第二期:

    $('.post').each(function() {
       $(this).easyface();
      });
    
    只需从
    $(document.ready
    块中运行插件即可

    解决方案

    试试这个

    var post = $('.post').children('a[name]').attr('name'); 
    
    更新

    如果只需要一个
    a
    元素,请执行以下操作:

    $(document).ready(function() {
        //run the plugin
    
        pNames = []
    
        $('.post').children('a[name]').each(function() {
            pNames.push($(this).attr('name'));
        });
    
        $('.postfoot').easyface({
            "post": pNames
        });
    });
    
    创建
    href
    时进行以下更改:

    var post = $('.post').children('a[name]')[0].attr('name'); 
    
    easyface=$('').addClass('easyface fb-like').attr({
    “data href”:settings.href.substring(0,settings.href.length-1)+“#”+settings.post.split(“p”)[1],//在此处连接href。
    

    更新的JSFIDLE:

    第1期:

    $('.post').each(function() {
       $(this).easyface();
      });
    
    children()
    将返回元素列表

    第二期:

    $('.post').each(function() {
       $(this).easyface();
      });
    
    只需从
    $(document.ready
    块中运行插件即可

    解决方案

    试试这个

    var post = $('.post').children('a[name]').attr('name'); 
    
    更新

    如果只需要一个
    a
    元素,请执行以下操作:

    $(document).ready(function() {
        //run the plugin
    
        pNames = []
    
        $('.post').children('a[name]').each(function() {
            pNames.push($(this).attr('name'));
        });
    
        $('.postfoot').easyface({
            "post": pNames
        });
    });
    
    创建
    href
    时进行以下更改:

    var post = $('.post').children('a[name]')[0].attr('name'); 
    
    easyface=$('').addClass('easyface fb-like').attr({
    “data href”:settings.href.substring(0,settings.href.length-1)+“#”+settings.post.split(“p”)[1],//在此处连接href。
    
    更新的JSFIDLE:

    我想这就是您要寻找的:

    主要变化是:

    • post ID是在
      each()
      循环中计算的,因为每个
      的post ID都不同。postfoot

      easyface = $('<div />').addClass('easyface fb-like').attr({
          "data-href": settings.href.substring(0, settings.href.length - 1) + "#" + settings.post.split("p")[1], // concatenate with your href here.
      
      这允许post ID被
      选项
      对象覆盖,这可能不是一个好主意

    • each()
      循环中也会创建
      easyface
      div,因为每个
      .postfoot
      的div都不同

      • 我想这就是你想要的:

        主要变化是:

        • post ID是在
          each()
          循环中计算的,因为每个
          的post ID都不同。postfoot

          easyface = $('<div />').addClass('easyface fb-like').attr({
              "data-href": settings.href.substring(0, settings.href.length - 1) + "#" + settings.post.split("p")[1], // concatenate with your href here.
          
          这允许post ID被
          选项
          对象覆盖,这可能不是一个好主意

        • each()
          循环中也会创建
          easyface
          div,因为每个
          .postfoot
          的div都不同


        与其为了获得分数而进行无用的编辑,还不如做些实际的事情。你修复了一些无知的东西,比如说效果很好?我是这样说的/很好…效果很好。天哪,你的编辑手头有这么多时间来试着获得编辑分数。你能发布一个示例的HTML内容吗
        。post
        div?是的,我会发布我有一把小提琴,我刚从我的网站上抓取了它的html。有人在等答案吗?@EasyBB我已经阅读了你的帖子很多次,但仍然不清楚你的问题是什么。请花点时间重新阅读并可能修改帖子,使其尽可能简洁:问题出在这里,它就是这样做的,这就是我想要的做。与其为了得到分数而进行无用的编辑,还不如做点实际的事情。你修复了一些无知的东西,比如说效果很好?我是这样说的/很好…效果很好。天哪,你的编辑们手头有这么多时间来试着获得编辑分数。你能发布一个例子的HTML内容吗
        。post
        div?是的,我会发布我有一把小提琴,我刚从我的网站上抓取了html。有人在等答案吗?@EasyBB我已经读了你的帖子很多次了,但仍然不清楚你的问题是什么。请花点时间重新阅读并可能修改帖子,使其尽可能简洁:问题出在这里,它就是这样做的,这就是我想要它做的。没问题,jQuery可以在对象集合上应用属性。@saeednamati它可以分配属性