Link to home
Start Free TrialLog in
Avatar of 3xtr3m3d
3xtr3m3d

asked on

Jquery button help

Hi

Im trying to create dynamic table which will insert row to end of the table and row contains a jquery button

row adding works fine. but button not working

i guess its because im adding button after document ready.

how to fix this problem?
Avatar of mhmr
mhmr
Flag of United Arab Emirates image

Hello
you can try like this :

	
<div id="mydiv">
</div>
<script> 
$("#mydiv").append('<table><tr><td>I Am The 1st</td></tr><tr><td><button id="btn">am a button</button></td></tr></table>');
$("#btn").live ( "click" , function () { alert('you pressed me??'); } );
</script>

Open in new window

Avatar of 3xtr3m3d
3xtr3m3d

ASKER

Hi

Thanks for reply and buttons now working but created  button is just a button and is it possible to change created button back to a jquery ui button?

current code is

$(document).ready(function() {

	$( '.Eb1' ).button({
		icons: {
			primary: "ui-icon-arrowthick-1-w"
		},
		text: false
	})
	.click(function() {
		$("#mydiv").append('<table><tr><td>I Am The 1st</td></tr><tr><td><button id="btn">am a button</button></td></tr></table>');
	});
	
					
	$("#btn").live ( "click" , function () { 
		alert('you pressed me??');
	});

});

Open in new window


<div id="mydiv"></div>
<button class="Eb1">add</button>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of mhmr
mhmr
Flag of United Arab Emirates image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial