Skip to content Skip to sidebar Skip to footer

Wordpress Tinymce Strips Onclick & Onchange (need Jquery)

Searched a long time to find a solution, but can't find one specific to my needs, so apologies if I've missed something. On my Wordpress site I have a page with a button, which in

Solution 1:

Well... yes you can handle it with pure jQuery.

I've made an example for you:

REMEMBER to add the jQuery library to your document, just before this <script> and if possible, just before </body> closing HTML tag :D

jQuery:

<script>
    $(document).ready(function () {
    var agree = $("#accept"); //we cache the element, dont worry

    $("#agreeCheckbox").click(function () {
        var checked_status = this.checked;
        if (checked_status === true) {
            agree.removeAttr("disabled");
        } else {
            agree.attr("disabled", "disabled");
        }
    });
    //we convert the button into an anchor
    agree.click(function () {
        window.location = $(this).data("href") + "&cbrblaccpt=true";
        });
    });
</script>

CSS: Because we are using a button instead of an anchor (<a></a>)

#accept {
    background: url(http://goo.gl/kCsKU3) center top no-repeat;
    color: #FFF;
    display: block;
    width: 200px;
    height: 44px;
    border:none;
    outline: none;
    cursor: pointer;
}
#accept:disabled {
    opacity: 0.6;
}
#accept:active {
    margin-top:2px;
}

And finally, the HTML: Note we're using data-href attribute for the link instead of a simple hrefbecause this is a button, not an anchor anymore.

<input id="agreeCheckbox"type="checkbox" />
<label for="agreeCheckbox">I agree to the terms</label>
<button data-href="link/?cbur=a"id="accept" disabled="disabled"></button>

JsFiddle: http://jsfiddle.net/n2zej2cg/

Post a Comment for "Wordpress Tinymce Strips Onclick & Onchange (need Jquery)"