jQuery在跨度中显示图像标题 - php

我想在span标签中显示图像标题。我使用此代码,但span标签中没有任何显示。

<script type="text/javascript" src="jquery-1.4.2.min.js" ></script>
<script type="text/javascript">
jQuery(document).ready(function( {
$('#thumb ul li a img').fadeIn(function() {
        var $this = $(this);
        $this.next('.showtitle').append($this.attr('title'));
    });
});
</script>
...
<div class="thumb"  id="thumb">
<ul class="ul">
<?php
$result = mysql_query("SELECT * FROM ..."); 
$strstr=1; 
while ($row = mysql_fetch_array($result))
{
echo '<li class="li"><a href="' . $row['link']. '"><img src="'.$row['image'].'" title="'.$row['title'].'" class="img'.$strstr.'" /></a><span class="showtitle" /></li>';
$strstr++;
}
?>
</ul>
</div>

我已经检查过,标题在数据库中不为空。我如何解决它?

参考方案

尝试此更改:

$('#thumb ul li a img').fadeIn(function() {
        var $this = $(this);
        $this.parent().next('.showtitle').append($this.attr('title'));
    });
});

我添加了.parent()。您的图像在图像的后面抓住了“下一个”,但是图像嵌套在链接内,并且标题跨度跟随该链接,而不是图像。

PHP:将数组值加在一起 - php

我相信这比标题听起来要难一些,但我可能完全错了。我有一个像这样的数组:[["londrina",15],["cascavel",34],["londrina",23],['tiradentes',34],['tiradentes',21]] 我希望能够采用通用…

PHP JQuery复选框 - php

我有以下片段。 var myData = { video: $("input[name='video[]']:checked").serialize(), sinopse: $("#sinopse").val(), dia: $("#dia").val(), quem: $(&#…

PHP strtotime困境 - php

有人可以解释为什么这在我的服务器上输出为true吗?date_default_timezone_set('Europe/Bucharest'); var_dump( strtotime('29.03.2015 03:00', time()) === strtotime('29.03.2015 04:00�…

PHP-全局变量的性能和内存问题 - php

假设情况:我在php中运行一个复杂的站点,并且我使用了很多全局变量。我可以将变量存储在现有的全局范围内,例如$_REQUEST['userInfo'],$_REQUEST['foo']和$_REQUEST['bar']等,然后将许多不同的内容放入请求范围内(这将是适当的用法,因为这些数据指的是要求自…

jQuery提交未传递的表单值 - php

我在初始页面加载时创建的表格中嵌入了一个表格:echo "<form id='showbooking' action='calendar.php' method='post'>"; echo "<td name='clickedcalid&#…