JSFiddle

  • Convert a description list to a table

    A fiddle for a work project.

    // Setup.
    var tableParts = {
    	tableSource: "div#table-transformer",
    	tableContainer: "div#table-receiver",
    	tableHtml: "<table><thead><tr></tr></thead><tbody></tbody></table>",
    	descriptionList: "div#table-transformer dl",
    	headerRow: "div#table-receiver thead tr",
    	tableBody ...
  • Legal use of a table?

    Is this a legal way to use a table? It is, after all, tabular data. Right? No?

    <h1>Legal use of a table?</h1>
    <table>
        <tr>
            <td>Tax map number: </td>
            <td>1234567890</td>
        </tr>
        <tr>
            <td>Parcel ID number: </td>
            <td>0987654321</td>
        </tr>
        <tr>
            <td>Permit number: </td>
            <td>A123459876</td>
        </tr>
    </table>
  • Format dates in place

    Format a date to remove the time. Display a helpful message if the date is invalid (besides "NaN"). This is for dates already on the page.

    $("span.unformattedDate").each(function(index){
    	var monthNames = [
    		"January", "February", "March",
    		"April", "May", "June", "July",
    		"August", "September", "October",
    		"November", "December"
    	];
    	var ...
  • Alert Box Trails #6 is the latest revision

    Some versions of IE create trails if the user tries to move a JS alert box called on window load.

    document.getElementById("btnClick").addEventListener("click", function() {
        alert("no trail here.");
    })
    
    alert("If you like to talk to tomoatoes...");
  • Password regex #3 is the latest revision

    No-Library (pure JS), HTML, CSS, JavaScript

    var regex, input, result;
    
    regex = /^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/;
    result = document.getElementById("result");
    input = document.getElementById("txtPasswordTest");
    
    document.getElementById("btnSubmit").addEventListener ...
  • Recursion

    A demo of recursively calling a function.

    var a = 1;
    var list = $("#list");
    var p = $("#test");
    
    var five = addUntilFive(a);
    $(test).html("Result: " + five);
    
    function addUntilFive(i ...
  • Pick a date

    A little code to pick a range of five dates that are neither on holidays nor weekends. This project was for work.

    // This first function is from another jsfiddle user.  I lost the link, though :/
    Date.prototype.addDays = function(days) {
    	var dat ...
  • CSS fun

    In a meeting? Play with CSS.

    <div>
        This text is just in the div.
        <span>This is text in a span.</span>
        <p>This is a paragraph.</p>
        <ol>
            <li>This<span>span</span></li>
            <li>That ...</li></ol></div>
  • Convert a description list to a table

    A fiddle for a work project.

    // Setup.
    var tableParts = {
    	tableSource: "div#table-transformer",
    	tableContainer: "div#table-receiver",
    	tableHtml: "<table><thead><tr></tr></thead><tbody></tbody></table>",
    	descriptionList: "div#table-transformer dl",
    	headerRow: "div#table-receiver thead tr",
    	tableBody ...
  • Copy text

    Copy text from one place to another.

    // Add my new paragraphs.
    $("div#destination1").html("<p></p><p></p>");
    $("div#destination2").html("<p></p><p></p>");
    
    // Get arrays of source and destination.
    var sourceParagraphs = $("div#source ...