Skip to content Skip to sidebar Skip to footer

Alternating Between Single And Double Quotes Indefinitely

I'm having an issue dealing with multiple embedded/alternating quotes that I'm hoping someone can help with. Here's the relevant code... displayMessage( 'post success!',

Solution 1:

Your approach is fundamentally wrong. Manually creating inline event handlers is almost always the wrong way to do it.

A better solution would be for example:

var shareLink = $( '<a>share</a>' )
                    .css({ cursor: 'pointer', 'font-size': '16px' })
                    .click( function() {
                            openSharePopup( textA , numberA, numberB );
                        });

var msg = $( "<p>if you'd like to share your post...</p>" )
              .css({ 'margin-top': '15px', 'margin-bottom': '15px' });

displayMessage( "post success!", shareLink.add( msg ) );

function displayMessage(heading, text){
  $("#displayMessageHeadingDiv").html(heading);
  $("#displayMessageBodyDiv").empty().append(text);
  $("#displayMessageParentDiv").show();
}

Essentially you should create the elements, add a click handler through the code, and add the elements directly to the container. This way you don't have to think about what kind of quotes to use and where.

(As another stylistic side note, it would be much better to use CSS classes to style the elements instead of inline styles.)


Post a Comment for "Alternating Between Single And Double Quotes Indefinitely"