Solution:

$($("button.primary")[0]).text()

-- or should we call this a workaround ?

Why will I have to wrap the element in another jQuery function call?

/Jesper

On Aug 27, 5:26 pm, Jesper Rønn-Jensen <jespe...@gmail.com> wrote:
> I'm trying to read (and then change) the text on two buttons in my
> user interface:
>
> <button class="primary approve">Approve selected</button>
> <button class="primary reject">Reject selected</button>
>
> Now depending on how many checkboxes (elsewhere) are selected, I want
> to change the text to something like "Approve 4 selected"
>
> I'm tried in vain to acess:
> $("button.primary").each(function(){
>   console.log( $('this').text() );//fails
>   console.log( $('this').html() );//fails
>
> });
>
> and for completeness sake I also tried $(this).value -- but of course
> it returns the .value attribute of the button.
>
> 2 questions:
>
> How do I access the text and change it?
> And where is that documented -- link wanted :)
>
> Any help appreciated :)
>
> /Jesper Rønn-Jensenwww.justaddwater.dk

Reply via email to