开发者

Insert User Email into Form Automatically jQuery

I am trying to grab text generated by javascript and开发者_JAVA百科 paste it into a forms input value field. This is what I have so far:

var txt=$('#grabemail').text();
$('#email').val(unescape(txt));

<p id="grabemail" style="color:#fff;">
  <script type="text/javascript">formData.display("email")</script>
</p>

The only problem is that when the jQuery grabs the text from #grabemail it not only takes the email but it also takes 'formData.display' so I end up with:

formData.display("email")user@email.com

In the field as opposed to just the email.

I cannot edit the JS inside of the #grabemail div.

Anybody have any ideas on how to fix this?


var txt = unescape($('#grabemail').text());
$('#email').val(txt.replace('formData.display("email")',''));

have you tried this way?


txt=txt.substring(25, txt.length); 

This should work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜