[jQuery] button value change

2009-11-11 Thread David pr
Hello,

I had an a href

a href=# id=hide2 title=Click to see detailsMore details/
a
$(this).text($(this).text() == 'More details' ? 'Hide details' : 'More
details');

and on click I changed the text from more to hide

I had to change the a href to

input type=button id=hide2B value=More details  /

How do I change the value text on click ?

David






Re: [jQuery] button value change

2009-11-11 Thread Joe Moore
David,

Here's one way, using the toggle event (really a click event, check out:
http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C...)

html
head
titleTest Page/title
script src='jquery.js' type='text/javascript'/script
script type=text/javascript
$(function() {
$('a.detailLink').toggle(
function(event) {
$(this).text('Hide Details');
},
function(event) {
$(this).text( 'More Details');
}
);

$('div[class^=hide-BAT]').hide();

});
/script
/head
body
a id='link1' class=detailLink href=#More Details/a
/body
/html


HTH,

Joe

On Wed, Nov 11, 2009 at 1:01 PM, David pr davidpric...@gmail.com wrote:

 Hello,

 I had an a href

 a href=# id=hide2 title=Click to see detailsMore details/
 a
 $(this).text($(this).text() == 'More details' ? 'Hide details' : 'More
 details');

 and on click I changed the text from more to hide

 I had to change the a href to

 input type=button id=hide2B value=More details  /

 How do I change the value text on click ?

 David