Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hiding the slider input box in jquery

I am using jquery Mobile 1.0.

I have this html code.

<label for="slider" class="ui-hidden-accessible">
    Input slider:
</label>
<input type="range" name="slider"   id="@(Model.QuestionNo)_slider" value="25" min="0" max="100" />

Its rendering like this: enter image description here

But I want to remove the red marked part. I want to show only slider part.

How can this be done?

like image 974
Chakradhar Avatar asked Jan 18 '12 15:01

Chakradhar


4 Answers

If you just want to get rid of the up/down arrows, you can wrap the input in an element with a specified width/height and overflow : hidden:

$(".ui-slider-input").wrap($('<div />').css({
    position : 'relative',
    display  : 'inline-block',
    height   : '36px',
    width    : '45px',
    overflow : 'hidden'
}));

Or as Frederic Hamidi stated, you can just hide the element all together and only a slider will be visible.

Here is a demo of the above code: http://jsfiddle.net/EWQ6n/1/

Also you can hide the input element with CSS (which is nice because you don't have to time the execution of the CSS like you do with JS):

.ui-slider-input {
    display : none !important;
}

Here is a demo using CSS: http://jsfiddle.net/EWQ6n/2/

Update

Instead of using the !important keyword, you can also make a more specific CSS rule so it is used over the jQuery Mobile classes. An example would be:

.ui-mobile .ui-page .ui-slider-input,
.ui-mobile .ui-dialog .ui-slider-input {
    display : none;
}
like image 101
Jasper Avatar answered Nov 15 '22 23:11

Jasper


input.ui-slider-input {
  display: none;
}
like image 22
TMB Avatar answered Nov 15 '22 22:11

TMB


You could hide the input control manually:

$("#yourPage").live("pageinit", function() {
    $(".ui-slider-input").hide();
});
like image 3
Frédéric Hamidi Avatar answered Nov 16 '22 00:11

Frédéric Hamidi


If you only want to get rid of the up/down arrow use type="text" data-type="range"

<input type="text" data-type="range" name="slider" id="@(Model.QuestionNo)_slider" value="25" min="0" max="100" />
like image 3
Frans Van Assche Avatar answered Nov 15 '22 23:11

Frans Van Assche