0

The blow script works but is also outputting a "type e" error in jquery...

I've been looking at this for about 20mins now and am failing to see the problem.

if ($('input[type="submit"]').hasClass('.grey-button')) {
        $(this).wrap('<span class="button grey-button"></span>');
    } else {
        $(this).wrap('<span class="button"></span>');
    }

What am i mssing ?

1
  • 1
    hasClass('.grey-button') should be hasClass('grey-button') without . Commented Jul 11, 2015 at 18:01

3 Answers 3

2

Don't need to use .classname in hasClass(). just call with classname without dot eg hasClass('classname');

just use

$('input[type="submit"]').hasClass('grey-button')
Sign up to request clarification or add additional context in comments.

1 Comment

urgh... thanks, been working for 12 days straight now. Think I need a break!
1

Checking with hasClass doesn't require to pass selector (the dot):

.hasClass('grey-button')//just use class name

Comments

0

To check the class we doesn't not need . with the selector. changed it as below

.hasClass('grey-button')

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.