So far,

So far,

Time is ticking and I have not start writing my report. I made a very cute Om-Nom (from Cut The Rope) yesterday🙂 Happy! Like this page for more cute stuffs – http://www.facebook.com/liuliankia

Om Nom

Anyway, today i finally solved the problem of unique entry in the table as well as removing item from the table.
Here are a few things that i learnt:

  1. To add items into array.
    array.push({var1: dataVar1, var2: dataVar2})
  2. To remove items from array – use splice() method for array.
    The splice() method adds/removes items to/from an array, and returns the removed item(s).
    array.splice(index,howmany,item1,.....,itemX)
    index – required. specifies where to add/remove items
    howmany – required. number of items to be removed. If ‘0’, no items will be removed.
    item1…itemx – optional. new items to be added.
  3. To access array item.
    array[index].var
  4. To display items in array.
    for (i-0; i<array.length; i++){
    $('#divID').append(array[i[.var1+' '+array[i].var2+'<br>');
  5. To show the ID of something.
    $(this).attr('id')
    let say id of a row:
    var $thisID = $(this).closest('tr').attr('id');
  6. To show index on the table.
    var index = $('#status_table tbody tr').last().index() + 1; //index() starts from 0.
  7. Selector variable
    [refer here]
    impt note: local variable can be called outside its function if it is declared without “var” keyword – to be proven later.
  8. Selector Wildcard
    • $('[id*=xx]') -given string xx anywhere
    • $('[id^=xx]') -start with xx
    • $('[id$=xx]') -end with xx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s