1

I'm trying to change the style of a textbox which has the attribute display:none;

I have another textbox and when I click inside the textbox, I should have the other one's css to be changed to display:inline-block!important;

<input type="text" id="linkField" class="form-control " placeholder="Enter the link to track">
<input type="text" id="emailField" class="form-control " placeholder="Enter the Email" style="display:none!important">
<input type="button" class="btn-success btn lightGreen" value="SHORTEN & TRACK">

I tried something like this but it is not working:

$(document).ready(function() {
    $('#linkField').click(function() {
        $("#emailField").css({"display": "inline-block!important"});
    }); 
});

Can anyone help me? Please let me know if you need additional details.

malkassem
  • 1,927
  • 1
  • 20
  • 39
user1012181
  • 8,290
  • 9
  • 60
  • 102

3 Answers3

3

You can use .show() instead of fiddling with inline css

$(document).ready(function() {
    $('#linkField').click(function() {
        $("#emailField").show();
    }); 
});

DEMO

Anton
  • 31,487
  • 5
  • 43
  • 54
1

Demo : http://jsfiddle.net/awladnas/a6NJk/614/

You were really close to your solution. Try like this:

$(document).ready(function() {
    $('#linkField').click(function() {

        $("#emailField").css('display','block');
    }); 
});
Awlad Liton
  • 9,260
  • 2
  • 26
  • 50
1

You can use the code below to set the display attribute:

$("#emailField").css("cssText", "display: inline-block !important");

I found this in the following post: How to apply !important using .css()?

Community
  • 1
  • 1
malkassem
  • 1,927
  • 1
  • 20
  • 39