<style type="text/css">
ul,li{list-style-type:none;}
目前分類:jQuery (6)
- Oct 21 Wed 2015 22:45
使用滑鼠拖曳列表中的元素做重新排序-jQuery UI Sortable Widget
- Sep 30 Wed 2015 22:57
jQuery 取得image原始大小
$("#discussMainBar .excerpt img").each(function (e) {
var $this = $(this);
- Sep 17 Thu 2015 20:05
存取iframe元素
$(function () {
$('#_iframe').load(function () {
- Jul 15 Wed 2015 08:25
Jquery lazyload with ajax
<img class="lazy" data-original="real.jpg" src="gray.jpg">
- Jan 21 Tue 2014 21:56
jQuery: Radio Button, Checkbox and Selecter
Trigger the event:
$("input[name='lom']").change(function(){
// Do something interesting here
});
Radio Button:
To get the selected value:
var v=$('input[name=Sex]:checked').val();
if( typeof(v) == 'undefined'){
//there's no button selected
}
To select radio button from value:
$("input[name=Sex][value='2']").attr('checked',true);
To select radio button from index:
$('input[name=Sex]')[1].checked = true;
Checkbox:
To see whether checkbox is checked:
$('#chk').is(':checked');
To set checkbox:
$("#chk1").attr("checked",'');
$("#chk2").attr("checked",true);
Selecter:
To get the selected value:
$('#selectList').val();
$('#selectList :selected').text();
To add a new option:
$('#selectList').addOption(value,text);
- Jan 12 Sun 2014 12:19
jQuery: placeholder fixed for IE 8
$(document).ready(function () {
$('[placeholder]').focus(function () {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function () {
var input = $(this);
if (input.val() == '' || input.val() == input.attr('placeholder')) {
input.addClass('placeholder');
input.val(input.attr('placeholder'));
}
}).blur();
$('[placeholder]').parents('form').submit(function () {
$(this).find('[placeholder]').each(function () {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
}
})
});
});
CSS Styling
::-webkit-input-placeholder {
color: red;
}
:-moz-placeholder {
color: red;
}
.placeholder {
color: #ccc;
}