Give help. Get help.

  • # June 12, 2013 at 7:30 pm

    Here is the scenario…

    I’m initially hiding an element(s) in css using **display: none**. I then use jQuery to make the element(s) visible by using **.show()**. By default the .show() method will make elements **display: block**. I need the elements to be **display: inline-block**. As a result I came up with the following methods to .show() inline-block elements. I prefer the first method, but I’m wondering if there’s best practice for doing this?

    **Method 1 (Preferred)**

    $.fn.showInBlock = function () {
    return this.css(‘display’, ‘inline-block’);

    In action…


    **Method 2**

    var showInBlock = function (){
    $(this).css(‘display’, ‘inline-block’);

    **Method 3**

    function showInBlock() {
    $(this).css(‘display’, ‘inline-block’);

    Any suggestions are welcome…Thank You.

    # June 12, 2013 at 8:06 pm

    You could do something like this:

    Utilizing `visibility: hidden;`. I prefer avoiding manipulating CSS directly from jQuery. Instead, I prefer toggling class names.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.