I need to find the class name specified in the input attribute using jquery
<Html>
<body>
<input type="text" class="name"/>
</body>
</Html>
here how i can find the class name using jquery
I need to find the class name specified in the input attribute using jquery
<Html>
<body>
<input type="text" class="name"/>
</body>
</Html>
here how i can find the class name using jquery
$('input').hasClass('name') ? alert('has class name') : alert('has no class name')
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" class="name"/>
use .hasClass
Description: Determine whether any of the matched elements are assigned the given class.
Try this:
var className = $('.name').attr('class');
alert(className);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" class="name"/>