Piotr Ciszewski
Piotr Ciszewski

Reputation: 1801

Is there any alternative to "a href" in html? I'm strictly mean "a"

Is there anything I can use instead of 'a' selector. Maybe something like <url href=""> or something similar. I'm trying to avoid 'a'. The reason for that is that I'm working with jQuery and its code modyfying every 'a' in the section. I want to keep some 'a's untouched. This is what i have: HTML:

                    <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...'));
    }
});     

});

It replaces my 'Noisettes on YouTube' (from html code) with 'read less...' (still working but wording changes. I was trying to use CSS but it still replaces it. I hope I made myself clear on this :) Thanks for help in advance.

Upvotes: 0

Views: 2324

Answers (2)

SLaks
SLaks

Reputation: 888195

You should use a more specific selector:

$posts.find('a.SomeClass')...

Then change the links that you want this to apply to to <a class="SomeClass">.

Upvotes: 1

Paul Tomblin
Paul Tomblin

Reputation: 182880

Give all the "a" that you want to change a particular class, say "changeable", and then change your selector from $('a', $posts) to $('a.changeable', $posts)

Upvotes: 0

Related Questions