How to simplify the if statements codes
<p>I am trying to simplfy the codes below to make them less ugly. Are there better way to do this? Thanks a lot.</p>

<pre><code>//the only difference is the append and after method after the $element.
     if($element.is('td')){
            $element.append(
                  $(document.createElement('div')).attr({'id': tooltipId}).addClass('js-tutorialTooltips').css({
                      'position': 'absolute',
                      'z-index':'9999', 
                      'color':'white',
                      'background-color': 'rgba(0, 0, 0, 0.8)',
                      'border': '1px solid #cccccc',
                      'border-radius': '0.5em',
                      'box-shadow': '0 0.2em 0.2em #111'})
                    .append(
                      $(document.createElement('div')).css({'padding': '0.5em 1em'}).html(text) //for more tool info add the following + '&lt;br/&gt;(' + verticalPosition + '-' + horizontalPosition + ':' + domId + ')'
                   )
                )
        }else{
            $element.after(
                      $(document.createElement('div')).attr({'id': tooltipId}).addClass('js-tutorialTooltips').css({
                        'position': 'absolute',
                        'z-index':'9999',
                        'width':'300px',
                        'color':'white',
                        'background-color': 'rgba(0, 0, 0, 0.8)',
                        'border': '1px solid #cccccc',
                        'border-radius': '0.5em',
                        'box-shadow': '0 0.2em 0.2em #111'})
                    .append(
                           $(document.createElement('div')).css({'padding': '0.5em 1em'}).html(text)  //for more tool info add the following + '&lt;br/&gt;(' + verticalPosition + '-' + horizontalPosition + ':' + domId + ')'  
                    )
            );  
        }




//The only difference is  prependTo and insertBefore method.. 


        if($element.is('td')){

                       $(document.createElement('img'))
                            .attr({src:'inc/images/help_bubble.png', title:'help Image', 'class': 'helpImg'})
                            .prependTo($element)
                            .css({'position':'absolute',
                                   'z-index':999,
                                   'top': xPos,
                                   'left': yPos
                             })

                   return true;
               }

                $(document.createElement('img'))
                            .attr({src:'inc/images/help_bubble.png', title:'help Image', 'class': 'helpImg'})
                            .insertBefore($element)
                            .css({'position':'absolute',
                                   'z-index':999,
                                   'top': xPos,
                                   'left': yPos

                                 })
</code></pre>
