ruby on rails ajax update css on page
Does anyone know how I can update the style attribute of a division using an Ajax request?
For example, I have a division I inlin开发者_如何学Goe style to display:hidden, and when a user clicks a link it changes the style to display:block
You don't need to perform an AJAX call to perform the above request. Plain old javascript will do. If you are using jQuery, try:
<div id="details">...</div
<a href="#" id="toggle">[Show]</a>
<script type="text/javascript">
$("#toggle").click(function () {
$("#details").show();
});
</script>
For prototype, try:
<div id="details">...</div
<a href="#" id="toggle">[Show]</a>
<script type="text/javascript">
Event.observe('toggle', 'click', function(event) {
$('details').show();
Event.stop(event);
});
</script>
精彩评论