1

If checkbox is checked, apply css to href

My HTML:

<a href="#"">             
    <input type="checkbox" checked="checked">0-3 Months
</a>

I do not have access to the HTML itself (SaaS Environment) to edit the CSS or to add an ID, name, or class. So the logic must be if any checkbox is checked.

Thank you.

James Anderson
  • 795
  • 1
  • 12
  • 21

4 Answers4

0

Something like this? Use jQuery.

$().ready(function() {
    var selected_option = $('#mySelectBox option:selected');

    if(selected_option) {
        // do something
        $('#SOMEELEMENT').css("background-color", "green");
    }
);
HelpNeeder
  • 5,933
  • 21
  • 80
  • 141
0

Do you need something like this?

In this simple example, when you click at checkbox it will apply a red background at tag A (href)

  <html>

  <style type="text/css">        
  .myNewCSS {
    background-color: red
  }
  </style>

  <a href="#" class="x">             
      <input type="checkbox" checked="checked" onclick="test(this)"/> 0-3 Months
  </a>

  <script type="text/javascript">
    function test(chk){
      chk.parentNode.className = "myNewCSS";
    }
  </script>

  </html>
patricK
  • 845
  • 9
  • 25
0

If you mean apply styles to <a> then it is not possible to do purely with css. You need to use javascript for that

jonasnas
  • 3,390
  • 1
  • 17
  • 30
0

You can actually select checked inputs with CSS in modern browsers:

input:checked {outline: 2px solid red;}
ralph.m
  • 12,558
  • 3
  • 19
  • 29