目前分類:jQuery (6)

瀏覽方式: 標題列表 簡短摘要

<style type="text/css">
ul,li{list-style-type:none;}

文章標籤

alueiphon 發表在 痞客邦 留言(0) 人氣()

$("#discussMainBar .excerpt img").each(function (e) {
var $this = $(this);

文章標籤

alueiphon 發表在 痞客邦 留言(0) 人氣()

$(function () {
$('#_iframe').load(function () {

文章標籤

alueiphon 發表在 痞客邦 留言(0) 人氣()

<img class="lazy" data-original="real.jpg" src="gray.jpg">

文章標籤

alueiphon 發表在 痞客邦 留言(0) 人氣()


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);

alueiphon 發表在 痞客邦 留言(0) 人氣()


$(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;
}


alueiphon 發表在 痞客邦 留言(0) 人氣()