0

using xml reading of contents of a particular thing i am adding checkboxes and its description.But the problem is that i want visual of my checkbox like radiobutton but it should work like checkbox.I mean i can check and uncheck it.Moreover on space of tick(in checkboxes),it should be dot(may be of any color if possible).

$(xml).find("Layer[Name='"+layerName+"']").find("IndustryComponent").each(function()
            {
                var layerDesciption= $(this).attr('Name');
                if($(this).is(':empty'))
                {
                    $(".InsideLayerContainer").append("<input type='checkbox' name='' value='' disabled='true'><label>"+layerDesciption+"</label><br/>");   
                }
                else
                {
                    $(".InsideLayerContainer").append("<input type='checkbox' name='' value=''><label>"+layerDesciption+"</label><br/>");
                }
            });

3 Answers 3

1

UPDATE

Check this DEMO http://jsfiddle.net/yeyene/Xqr4n/2/

HTML

<input class="myCheck" type="checkbox" name="vehicle" value="Bike">check 1<br />
<input class="myCheck" type="checkbox" name="vehicle" value="Bike">check 2<br />
<input class="myCheck" type="checkbox" name="vehicle" value="Bike">check 3<br />

JQUERY

$('input[type=checkbox]').each(function(){
    $(this).wrap('<span class="circle">');
});

$('.circle').on("click", function(){
    if($(this).css("background-color") == 'rgb(223, 223, 223)') { 
        $(this).find('.myCheck').prop('checked', true);
        $(this).css({'background-color':'rgb(0, 64, 212)'});
    }
    else {
        $(this).find('.myCheck').prop('checked', false);
        $(this).css({'background-color':'rgb(223, 223, 223)'});
    }
});
0

I wouldn't really recommend it, but you can always make radio buttons work like checkboxes, if that's what you're really after ?

$('input[type="radio"]').on('click', function() {
    this.checked = !$(this).data('checked')
    $(this).data('checked', !$(this).data('checked'));
});

FIDDLE

1
  • you got me right..i more thing i want to give color to radio button and on mouse click its color should change and regain its color on another click and so on Commented Jun 19, 2013 at 10:50
0

You need to use a image overlay for that.

Create two images one for unchecked view and one for checked view then based on the click value update a hidden checkbox and change the visible image also

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.