2009-01-02 93 views

回答

2

所以基本上在你的榜样的过程是这样的:

  1. 用户点击与名pmAmne 的链接说用户名
  2. 输入(pmName? )得到充满'用户名'(标题属性的段落父母点击?

如果是,则下面的代码应工作:

jQuery(function() { 
    jQuery('a.addTitleTag').click(function() { 
     titleText = jQuery(this).parents('p').attr('title'); 
     jQuery("input[name='pmName']").val(titleText); 
    }); 
}); 
1

一些额外的问题,1)<title>标签只是用户名或它是否有额外的文本。

基地下面的代码:

jQuery(function() { 
    jQuery('a.addTitleTag').click(function() { 
     titleText = document.title; // Placed in new var incase of extra manipulation needed. 
     jQuery("input[name='username']").val(titleText); 
    }); 
}); 
0

我想你想要的是得到的用户名丝毫不差属性p标签的“Firsname姓氏”的一部分。

$("p[title='username']").find('a').click(function{ //Onclick for the a in the p tag 
    contentOfP = $("p[title='username']").html(); //get the content of the p tag, including the <a> tag 
    positionOfDash = contentOfP.indexOf('-'); //We need the position of the dash to determine where the 'Firstname Lastname' part of the P tag ends 
    names = contentOfP.substr(0, positionOfDash); //Get the start of the P tag withouth the dash 
    $("input[name='pmAmne']").val(names); //Set the value of the input 
    return false; //Block the default event for the link so it doesn't jump to the top of the page on long pages 
}); 

这应该做的伎俩

0

stuartloxton家伙真好!作品篦。但它为我造成了问题。

我媒体链接有:

<script type="text/javascript"> 
(function update() 
    { 
     $.ajax(
     { 
     type: 'GET', 
     url: '/doGet/pmKontakter.php', 
     timeout: 2000, 

      success: function(data) 
      { 
       $("#pmKontakter").html(data); 
       $("#loadingComponent").html(''); 
       window.setTimeout(update, 10000); 
      }, 

      error: function (XMLHttpRequest, textStatus, errorThrown) 
      { 
       $("#pmKontakter").html('<h3>Din kontaktlista kunde inte hämtas för tillfället.</h3>'); 
       window.setTimeout(update, 60000); 
      } 
     }); 
    })(jQuery); 
</script> 

当我使用此代码abow和你的代码,你的代码dosent工作。

+0

你怎么实现他的代码,应该没有碰撞,但是,当你的update()函数不需要任何参数时,为什么要用(jQuery)参数调用updae函数呢? – 2009-01-02 16:57:30

相关问题