Iladarsda
Iladarsda

Reputation: 10696

JavaScript - check if this (current element) has a class ending with

To select input ending with -top I can sue the following:

$("input[class$='-top'],input[class*='-top ']")

But, how to check if this end with -top?

$('Input').keyup( function(){

 // How to check if $(this).prop('class') end with  "-top"

});

How to check if $(this).prop('class') end with "-top"

Any suggestions much appreciated.

Upvotes: 1

Views: 1293

Answers (1)

Pointy
Pointy

Reputation: 413717

You're looking for .is():

if ($(this).is('[class*=-top]')) { ... }

edit — substitute in the selector of your choice of course ...

Upvotes: 7

Related Questions