开发者

jQuery html() on iPad

var partnerId = $('.partnerId').html();

The code above pulls the inner html from

<span id="_ctl0_ContentPlaceHolder1_lPartnerID" class="partnerId">1122</span></td>

correctly on IE7 and firefox. The code fails on iPad.

alert(partnerId) returns "1122" corr开发者_如何学Pythonectly on FireFox and IE7. But, on iPad I get

<a href="tel:1122">1122</a> as my return value.

How can I fix this?


Just a moment before I posted, I figured out how to fix the problem. Someone else may benefit from this solution so I posted anyhow. The issue is due to iPads telephone number detection. iPad wraps what it believes to be a telephone# in some HTML (what you see above). In my case, I do not need or want phone number detection. So I stuck

<meta name = "format-detection" content = "telephone=no" />

in the master page header. Problem solved.


Have you tried using text();

var partnerId = $('.partnerId').text();


I assume you only want the number:

$('.partnerId').text();


Something tells me that you will not be able to overcome this for particular sub tree in the DOM. For global solution see P.Brian.Mackey's answer. Using .text() is the most reliable and effective option I think.

In fact on IE or FF you may get the same if you have for example Skype plugin installed and the number looks like a phone number.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜