Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not create inline HTML, instead use the relevant jQuery functions #62

Open
softwarespot opened this issue Aug 11, 2015 · 0 comments
Open

Comments

@softwarespot
Copy link

It's best to do something like this when creating a new HTML element...

// Close button
var $button = $('<button/>')
        .attr('type', 'button')
        .addClass('close')
        .attr('data-dismiss', 'alert')
        .attr('aria-label', 'Close'),

    // The small 'x'
    $cross = $('<span/>')
        .attr('aria-hidden', 'true')
        .html('&times;');

// Append the cross to the button element
$button.append($cross);

// Append the close button to the alert and add the class
// that it's dimissible
$alert.append($button)
    .addClass('alert-dismissible');

You can see that I have done this in my fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant