English 中文(简体)
如果多米物体仅是一个要素,则未定义的焦土变量回归
原标题:Jquery variable returning undefined if the Dom object was only one element

我在言语中使用了这一代码,以回馈媒体上载录的用户形象。

如果只有上载机屏幕所恢复的形象,则该代码不会重回图像弧。

The Jquery Code:

window.send_to_editor = function(html) {
alert(html);
imgurlv = jQuery(html).find( img ).attr( src );
alert(imgurlv);
     jQuery(targetfield3).val(imgurlv);
     tb_remove();
}

例如:

由上载体交回的法典是:

<a class="shutterset_" href= http://localhost/1/wp-content/gallery/bm/01.jpg  title=  ><img src= http://localhost/1/wp-content/gallery/bm/thumbs/thumbs_01.jpg  alt= 01  class= ngg-singlepic ngg-none  /></a>

The img src is re as this: http:// localhost/1/wp-content/gallery/bm/thumbs/thumbs_01.jpg

但是,如果由上载人返回的代码是:

<img src= http://localhost/1/wp-content/gallery/bm/thumbs/thumbs_01.jpg  alt= 01  class= ngg-singlepic ngg-none  />

舱位代码返回un Defin

什么是错的?

最佳回答

你们可以赞扬:

imgurlv = jQuery("<div>" + html + "</div>").find( img ).attr( src );

问题在于目前要素的儿童。 在第二种情况下,<代码>img 要素是最高层次,因此没有一个孩子可以找到<条码>src 的财产。

问题回答

暂无回答




相关问题
PHP DOM - accessing newly added nodes

I use the following to get a html document into DOM: $dom = new domDocument( 1.0 , utf-8 ); $dom->loadHTML($html) and then I add some new content to an element in the html: $element = $dom->...

XML DOM parsing br tag

I need to parse a xml string to obtain the xml DOM, the problem I m facing is with the self closing html tag like <br /> giving me the error of Tag mismatch expected </br>. I m aware this ...

How to get a flash url in a webpage using a webframe?

As we know , When we load frame from webpage of safari, we will invoke the delegate methods of webkit informal protocol(WebFrameLoadDelegate): webView:didStartProvisionalLoadForFrame: webView:...

热门标签