在Span中查找文本并在警报中显示(Finding text within a Span and displaying in an alert)
在我当前的页面上,我目前有一个在iframe中呈现的范围:
<span id="SpanID_ctrlHelp_lblHelp">HelpText</span>使用以下代码,我可以在警报中显示“HelpText”:
$('div[id*="MyControl"]').find("[id*='_fraDefaultFrame']") .contents() .each(function () { var txtBox = $('#SpanID_ctrlHelp_lblHelp').html(); alert(txtBox); });上面的代码运行良好,但我想为给定屏幕上的每个帮助文本实例激活一个警报。 请注意,所有可用的帮助文本都有一个span ID,其中包含以下“_ctrlHelp_lblHelp”
希望有人能理解这一点并协助......
On my current page I currently have a span which is rendered within an iframe:
<span id="SpanID_ctrlHelp_lblHelp">HelpText</span>With the below code I am able to display 'HelpText' within an alert:
$('div[id*="MyControl"]').find("[id*='_fraDefaultFrame']") .contents() .each(function () { var txtBox = $('#SpanID_ctrlHelp_lblHelp').html(); alert(txtBox); });The above code works well however I would like to activate an alert for every instance of help text on a given screen. Note all available help text has a span ID which contains the following "_ctrlHelp_lblHelp"
Hope someone can make sense of this and assist...
最满意答案
这样做:
var txtBox = $('[id$="_ctrlHelp_lblHelp"]').html(); // id ends by或这个:
var txtBox = $('[id*="_ctrlHelp_lblHelp"]').html(); // id contains或者你可以试试这个:
$('[id$="_ctrlHelp_lblHelp"]').each(function(){ alert(this.innerHTML); });This would do:
var txtBox = $('[id$="_ctrlHelp_lblHelp"]').html(); // id ends byor this:
var txtBox = $('[id*="_ctrlHelp_lblHelp"]').html(); // id containsOr you may try this:
$('[id$="_ctrlHelp_lblHelp"]').each(function(){ alert(this.innerHTML); });更多推荐
发布评论