Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 612249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:52:21+00:00 2026-05-13T17:52:21+00:00

<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd> <html><head> <meta http-equiv=’Content-Type’ content=’text/html; charset=UTF-8′> <title>If

  • 0
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
<title>If Else</title>
<script type="text/javascript" src="/jquery-1.3.2.min.js"></script>
<style  TYPE="text/css"> 

    .show                                       { display:block; }
    .hide                                       { display:none; }

</style>
</head>
<body>
<script type="text/javascript">
$('#portweb').click(function() {

    if ('li[value*=web] img'.hasClass("hide")) {
        $('li[value*=web] img').removeClass('hide').addClass('show');
    }
    else if ('li[value*=web] img'.hasClass("show")) {
        $('li[value*=web] img').removeClass('show').addClass('hide');
    }

});
</script>

<a href="#" id="portweb">Web</a>
<br />

        <ul id="portfolioWrapperSet">
            <li value="web dev"><a href="#"><img src="images/portfilio/ph1.jpg" class="hide" /></a></li>
            <li value="web packaging print media"><a href="#"><img src="images/portfilio/ph2.jpg" class="hide" /></a></li>
            <li value="tv packaging print media"><a href="#"><img src="images/portfilio/ph3.jpg" class="hide" /></a></li>
            <li value="web packaging print media social"><a href="#"><img src="images/portfilio/ph4.jpg" class="hide" /></a></li>
        </ul>


</body>
</html>

So the problem im having is actually getting my function to remove the ‘.hide’ class then add the ‘.show’ class through my if statement.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:52:21+00:00Added an answer on May 13, 2026 at 5:52 pm

    You are trying to manipulate the DOM before it is ready. Try wrapping your code in a document.ready statement. Also in your ifs you are trying to call the hasClass method on a string which is not defined:

    $(function() {
    
        $('#portweb').click(function() {
    
            if ($('li[value*=web] img').hasClass("hide")) {
                $('li[value*=web] img').removeClass('hide').addClass('show');
            }
            else if ($('li[value*=web] img').hasClass("show")) {
                $('li[value*=web] img').removeClass('show').addClass('hide');
            }
    
        });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd> <html> <head> <script type=text/javascript> function init(){
This is my code: <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd> <html> <head>
I have this little jQuery plugin: <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd>
<?php //require 'includes/db.inc.php'; require 'includes/configs.inc.php'; ?> <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd>
I have the following HTML <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> <html
I have a frame page.... <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Frameset//EN http://www.w3.org/TR/html4/frameset.dtd> <html>
many doctype use a url link like this <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN
Here are the first few lines of my page: <!DOCTYPE html PUBLIC -//W3C//DTD HTML
I have a page that had the doctype: <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01
Currently, I have a code like this <!DOCTYPE HTML PUBLIC -// W3C//DTD HTML 4.01

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.