To Examples

JQuery Examples

Directions

JQuery1 Example

--- JQuery/app/views/test/view1.html.erb ----------------------
<h2>JQuery1 Example</h2>

<p id="comment">The weather has been getting colder lately.</p>

<p><button id="btn" 
  onclick="document.getElementById('comment').style.visibility = 
          'hidden';">Hide Comment</button></p>

JQuery2 Example

--- JQuery/app/views/test/view1.html.erb ----------------------
<h2>JQuery2 Example</h2>

<p id="comment">The weather has been getting colder lately.</p>

<p><button id="btn" 
  onclick="document.getElementById('comment').style.fontSize = 
          '500%';">Hide Comment</button></p>

JQuery3 Example

--- JQuery/app/views/test/view1.html.erb ----------------------
<h2>JQuery3 Example</h2>

<p id="comment">The weather has been getting colder lately.</p>

<p><button id="btn" onclick="$('#comment').hide( );")>
     Hide Comment</button></p>

JQuery4 Example

--- JQuery/app/views/test/view1.html.erb ----------------------
<h2>JQuery4 Example</h2>

<p id="comment">The weather has been getting colder lately.</p>

<p><button id="btn" 
           onclick="$('#comment').css('font-size', '200px');")>
    Hide Comment</button></p>

JQuery5 Example

--- JQuery/app/views/test/view1.html.erb ----------------------
<script type='text/javascript'>
hideComment = function( ) {
  document.getElementById('comment').style.visibility = 'hidden';
}
</script>

<h2>JQuery5 Example</h2>

<p id="comment">The weather has been getting colder lately.</p>

<p><button id="btn" 
  onclick="hideComment( );">Hide Comment</button></p>

JQuery6 Example

--- JQuery/app/views/test/view1.html.erb ----------------------
<script type='text/javascript'>
$('#btn').click = function( ) {
  $('#comment').hide( );
});
</script>

<h2>JQuery6 Example</h2>

<p id="comment">The weather has been getting colder lately.</p>

<p><button id="btn">Hide Comment</button></p>

JQuery7 Example

--- JQuery/app/views/test/view1.html.erb ----------------------
<script type='text/javascript'>
$('document').ready(function( ) {
  $('#btn').click(function( ) {
    $('#comment').hide( );
  });
});
</script>

<h2>JQuery7 Example</h2>

<p id="comment">The weather has been getting colder lately.</p>

<p><button id="btn">Hide Comment</button></p>

JQuery8 Example

--- JQuery/app/views/test/view1.html.erb ----------------------
<script type='text/javascript'>
$('document').ready(function( ) {
  $('#btn').click(function( ) {
    $('#comment').hide( );
  });
});
</script>

<h2>JQuery8 Example</h2>

<p id="comment">The weather has been getting colder lately.</p>

<p><%= button_tag 'Hide Comment', id: 'btn' </p>

JQuery9 Example

--- JQuery/app/assets/javascripts/application.js ---------------
$('document').ready(function( ) {
  $('#btn').click(function( ) {
    $('#comment').hide( );
  });
});

--- JQuery/app/views/test/view1.html.erb ----------------------
<h2>JQuery9 Example</h2>

<p id="comment">The weather has been getting colder lately.</p>

<p><%= button_tag 'Hide Comment', id: 'btn' </p>

JQuery10 Example

--- JQuery/app/assets/javascript/test.coffee ----------------
$('document').ready ->
  $('#btn').click ->
    $('#comment').hide( );

--- JQuery/app/views/test/view1.html.erb ----------------------
<h2>JQuery10 Example</h2>

<p id="comment">The weather has been getting colder lately.</p>

<p><%= button_tag 'Hide Comment', id: 'btn' </p>