有什麼我可以用來代替'a'選擇器。也許像<url href="">
或類似的東西。我試圖避免'一個'。原因是我正在使用jQuery和它的代碼來實現部分中的每個'a'。我想保留一些'未觸及的。這是我有: HTML:在html中有沒有其他的「a href」?我嚴格意思是「a」
<div> <!-- █ POST █ -->
<h3>14 June 2012 - Noisettes for Spotify</h3>
<p>
We have supplied a sound equipment for the Noisettes concert on Spotify company event. Please enjoy <a class="inlink" target="_blank" href="http://www.youtube.com/watch?v=KRFHiBW9RE8">Noisettes on YouTube</a>.
</p>
</div>
JQUERY:
$(document).ready(function(){
var $posts = $('#items > div');
var maxHeight = 32;
$('a', $posts).live('click', function(){
var $par = $(this).prev('p');
var oH = parseInt($par.attr('class'));
if($par.height() == oH){
$par.animate({
'height': maxHeight
}, 'medium');
$(this).text('read more...');
}else{
$par.animate({
'height': oH
}, 'medium');
$(this).text('read less...');
}
});
$posts.each(function(){
if($('p', this).height() > maxHeight){
$('p', this)
.attr('class', $('p', this).height())
.css('height', maxHeight+'px');
$(this).append($('<a class="link">').text('read more...'));
}
});
});
它代替了我''在YouTube上的Noisettes'(從html代碼)'閱讀少...'(仍然工作,但措辭有所改變,我試圖使用CSS,但它仍然取代它) 我希望我讓自己明確此:)感謝您的幫助提前。
問題是這些「a」不存在於html中。只有當特定帖子較大時,它們纔會被jQuery所佔用。所以我不能添加任何類到這些元素。如果我理解得好。 – 2012-07-20 20:56:05
看起來他們給了一個「鏈接」類,所以使用'$('a.link',$ posts)' – 2012-07-20 21:01:00
!!!!加工。非常感謝 :) – 2012-07-20 21:26:09