Html
<div id="mydiv" class="foo bar"></div>
1. Js below Reture true.
$( "#mydiv" ).hasClass( "foo" )
2. Js below Reture false.
$( "#mydiv" ).hasClass( "quux" )
*实现通过判断是否存在对应的 class,输出 true 或 false
(function($) { //成功跳转 $(".button").click(function(){ setTimeout(function () { if ( $( ".subscription_message" ).hasClass( "success" ) ) { window.location.href="<?php echo get_bloginfo('url');?>/thanks/"; } }, 2000); }); })(jQuery);