PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun May 28, 2017 5:14 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Fri Oct 07, 2016 12:03 pm 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4203
Location: United Kingdom
....how? that's the funny thing about jFiddle, if you are not use to it, you see the code, but it doesn't show the jQuery to attach.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Fri Oct 07, 2016 12:09 pm 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6243
Location: Montreal, Canada
simonmlewis wrote:
....how? that's the funny thing about jFiddle, if you are not use to it, you see the code, but it doesn't show the jQuery to attach.

It does. Click the cog in the JS pane. At least in this case, though, the particular version of jQuery doesn't much matter. Whatever you're already using on the site is probably fine.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Fri Oct 07, 2016 12:11 pm 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4203
Location: United Kingdom
Syntax: [ Download ] [ Hide ]
  <script type="text/javascript" src="//code.jquery.com/jquery-2.2.4.js"></script>
  <script>
  $('.faq-tile input').change(function(event) {
        if ($(this).is(':checked')) {
        $(this).parent().css('background-color', 'pink');
  } else {
        $(this).parent().css('background-color', '#F5F5F5')
  }
});
  </script>


???

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Fri Oct 07, 2016 12:12 pm 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6243
Location: Montreal, Canada
You'll want to wrap it in a document ready, but that's the gist of it, yeah.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Fri Oct 07, 2016 12:15 pm 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4203
Location: United Kingdom
Sorry for being thick:

Syntax: [ Download ] [ Hide ]
  <script>
  var mydocument = function() {
  $('.faq-tile input').change(function(event) {
        if ($(this).is(':checked')) {
        $(this).parent().css('background-color', 'pink');
  } else {
        $(this).parent().css('background-color', '#F5F5F5')
  }
});}
  </script>

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Fri Oct 07, 2016 12:19 pm 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6243
Location: Montreal, Canada
Syntax: [ Download ] [ Hide ]
$(document).ready(function() {
    $('.faq-tile input').change(function(event) {
        if ($(this).is(':checked')) {
            $(this).parent().css('background-color', 'pink');
        } else {
            $(this).parent().css('background-color', '#F5F5F5')
        }
    });
});


or just

Syntax: [ Download ] [ Hide ]
$(function() {
    $('.faq-tile input').change(function(event) {
        if ($(this).is(':checked')) {
            $(this).parent().css('background-color', 'pink');
        } else {
            $(this).parent().css('background-color', '#F5F5F5')
        }
    });
});

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Fri Oct 07, 2016 12:22 pm 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6243
Location: Montreal, Canada
Again, though, you should probably have your JS split out into their own files and the various listeners grouped into a single doc ready block.

Syntax: [ Download ] [ Hide ]
$(document).ready(function() {
    // Stuff here...
    $('.faq-tile input').change(function(event) {
        if ($(this).is(':checked')) {
            $(this).parent().css('background-color', 'pink');
        } else {
            $(this).parent().css('background-color', '#F5F5F5')
        }
    });
    // More stuff down here...
});


Syntax: [ Download ] [ Hide ]
        ...
        <script src="//code.jquery.com/jquery-2.2.4.js"></script>
        <script src="/assets/js/your-script.js"></script>
    </body>
</html>
 

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Fri Oct 07, 2016 12:42 pm 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4203
Location: United Kingdom
gotcha ta.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Wed Nov 16, 2016 7:54 am 
Offline
Forum Newbie

Joined: Thu Oct 20, 2016 6:33 am
Posts: 7
Yes i appreciate with all information . w3school.com is also very informative site to get html, css, javascript knowledge..


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group