MediaWiki:Common.js: Difference between revisions

More JS testing
(Initial javascript testing.)
(More JS testing)
Line 32: Line 32:
   //Testing out adding input boxes
   //Testing out adding input boxes
   if ($('#js-test').length > 0) {
   if ($('#js-test').length > 0) {
    var newTable = document.createElement('table');
    var newRow = document.createElement('tr');
    var newCell = document.createElement('td');
     var newInput = document.createElement('input');
     var newInput = document.createElement('input');
     newInput.setAttribute('type', 'text');
     newInput.setAttribute('type', 'number');
     newInput.setAttribute('id', 'txtInput1');
     newInput.setAttribute('id', 'txtInput1');
     $('#js-test').append(newInput);
    newCell.append(newInput);
    newRow.append(newCell);
    newCell = document.createElement('td');
    newInput = document.createElement('button');
    newInput.textContent = "Click Here!";
    newInput.setAttribute('id', 'btnTest');
    newInput.addEventListener('click', (function(){
      console.log('clicked');
      $('#btnTest').text($('#txtInput1')[0].value);
    }));
    newCell.append(newInput);
    newRow.append(newCell);
    newTable.append(newRow);
     $('#js-test').append(newTable)
   }
   }
}
}
);
);