My code parses an external page and creates a div to display that page's data. I found a script here on stack overflow that is supposed to stretch a text to a div width, this one http://jsfiddle.net/webtiki/DPRr9/, but I'm not being able to make it work with my script, it looks like it is not working because my code's div is generated dynamically, so the jQuery code actually isn't seeing any div to integrate to.
我的代码解析外部页面并创建一个div来显示该页面的数据。我在这里发现了一个堆栈溢出的脚本,它应该将文本拉伸到div宽度,这个http://jsfiddle.net/webtiki/DPRr9/,但是我无法使它与我的脚本一起工作,看起来它不起作用,因为我的代码的div是动态生成的,所以jQuery代码实际上没有看到要集成的任何div。
<?php
$xml = new DOMDocument();
@$xml->loadHTMLFile('http://v2.afilio.com.br/aff/aff_boutique_show_ads.php?boutiqueid=37930-895777¤cypos=0&display_img=1&diplay_name=1&diplay_price=1&thumbsize=80%&truncate_desc=1&numrows=1&numcols=9&colorname=000000&colorprice=E30000&bkcolor=FFFFFF&bordercolor=FFFFFF&self_target=0&');
$products = array();
//Loop through each <td> tag in the dom and extract inner html
foreach($xml->getElementsByTagName('td') as $p) {
$children = $p->childNodes;
$phtml = '';
foreach ($children as $child)
{
$phtml.= $p->ownerDocument->saveHTML($child);
}
echo '<div id="mainproductafilioright"><div class="product">' . $phtml . '</div></div>';
}
?>
The line that generates the div is:
生成div的行是:
echo '<div id="mainproductafilioright"><div class="product">' . $phtml . '</div></div>';
2 个解决方案
#1
0
Use "text-align: justify;" property. and give width of the Div in % or in em not in pixels.
使用“text-align:justify;”属性。并以%为单位给出Div的宽度,或以像素为单位给出em的宽度。
#2
0
$('#mainproductafilioright').delegate('.product', 'change', function(){
// apply your script here
});
And maybe on resize event apply it too.
也许在调整大小事件也适用它。
#1
0
Use "text-align: justify;" property. and give width of the Div in % or in em not in pixels.
使用“text-align:justify;”属性。并以%为单位给出Div的宽度,或以像素为单位给出em的宽度。
#2
0
$('#mainproductafilioright').delegate('.product', 'change', function(){
// apply your script here
});
And maybe on resize event apply it too.
也许在调整大小事件也适用它。