JSFiddle

  • Difference between class and ID in CSS

    In answer to a question at http://stackoverflow.com/questions/15356660/difference-between-id-and-class/15356814?noredirect=1#comment21695137_15356814

    <h1>This title shouldn't have the same ID as the paragraph, because IDs are <em>unique identifiers</em>.</h1>
    <p id="para1" class="paragraph">This paragraph has an ...</p>
  • Make links conditionally inherit font size and colour #5 is the latest revision

    In response to a question at http://stackoverflow.com/questions/15271739/conditional-inherit-font-size-and-color/15271794

    <div id="container">
        Default text color
        <br />
        <br />
        <a href="#">Red link . default font</a>
        <br />
        <h1><a href="#">Green link - Arial 22px</a></h1>
        <br />
        <span style="font-size: 18px"><a href="#">Red link - Times 18px</a></span>
    </div>
  • Make an iterator loop through indices #88 is the latest revision

    In response to a question at http://stackoverflow.com/questions/15221097/jquery-slider-last-to-first-transition/15271723

    function slider(sel, intr , i){
        var _slider = this;
        this.ind = i;
        this.selector = sel;
        this.slide = [];
        this.slide_active = 0;
        this ...
  • Calculating date differences from an input date #33 is the latest revision

    In answer to the question at http://stackoverflow.com/questions/15249044/calculate-date-difference-in-jquery/15250294#15250294

        $('#Field1')
            .simpleDatePicker()
            .on('change', function passValue(){
                $('#Field2').val(calculateDaysFromNow($('#Field1').val()))
            });
        
        function calculateDaysFromNow(dateString){
            return moment.duration(moment(dateString,'MMM ...
  • Vertical margins don't collapse; inline horizontal paddings, borders and margins do

    In answer to the question at http://stackoverflow.com/questions/15246917/cant-understand-a-paragraph-in-css-the-definitive-guide-3rd-edition/15247381

    <div>
        <span>A span.</span>
        <span>Another span.</span>
    </div>
  • Vertical margins collapse

    In answer to the question at http://stackoverflow.com/questions/15246917/cant-understand-a-paragraph-in-css-the-definitive-guide-3rd-edition/15247381

    <div>
        <p>A paragraph</p>
        <p>Another paragraph</p>
    </div>
  • Chrome rendering issue #3 is the latest revision

    In response to the question at http://stackoverflow.com/questions/15152470/chrome-rendering-issue-fixed-position-anchor-with-ul-in-body

        <div id="sidebar">
            <a href="#s1">Link #1</a><br/>
            <a href="#s2">Link #2</a>
        </div>
    
        <div id="content">
            <div id="s1">
                <a href="#s1">Link #1 TARGET</a>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,
                sed do eiusmod tempor incididunt ...</p></div></div>
  • Extend the last cell to fill remaining space #189 is the latest revision

    In response to the question at http://stackoverflow.com/questions/15134550/html-css-table-how-do-i-increase-width-of-table-without-affecting-width-of-cell

    <table>
    	<tbody>
    		<tr>
    			<td>
    				Hello
    			</td>
    			<td>
    				Hi
    			</td>
    			<td>
    				How do you do
    			</td>
    			<td>
    			</td>
    		</tr>
    	</tbody>
    </table>
  • Change an element's tagName #77 is the latest revision

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

    // Grab the original element
    var original    = document.getElementById('e93');
    // Create a replacement tag of the desired type
    var replacement = document ...
  • Lock all checkboxes in a column #14 is the latest revision

    In response to the question at http://stackoverflow.com/questions/15086000/how-to-disable-all-checkbox-within-the-column-when-button-is-clicked/

    $(function lockTrigger(){
    	$('.lockButton').each(function setUpToggleFunction(){
    		// Keep a record of whether checkboxes are currently locked or not
    		var locked = false ...