Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <body>
		<div class="wrapper">
			<div class="main">
				<form class="generate" method="post">
					<h1 class="generate-title">Dinamički Event handler</h1>
					<input type="text" class="generate-input" placeholder="Unesite tekst">
					<input type="submit" class="generate-submit" value="Napravite elemenat">
				</form>
        <p id="message"></p>
				<ul id="links">
				</ul>
			</div>
		</div>
	</body>
              
            
!

CSS

              
                /*------------------------------------*\
    RESET
\*------------------------------------*/

*,
*:after,
*:before {
	margin:0;
	padding:0;
	box-sizing:border-box;
	-webkit-box-sizing:border-box;
	-moz-box-sizing:border-box;
	-webkit-font-smoothing:antialiased;
	font-smoothing:antialiased;
	text-rendering:optimizeLegibility;
}
body {
	font:400 13px/1.4 'Helvetica Neue', Helvetica, Arial, sans-serif;
	background:#333;
}

/*------------------------------------*\
    STRUCTURE
\*------------------------------------*/

.wrapper {
	max-width:1280px;
	margin:0 auto;
}
.header {
	padding:15px 25px;
	margin:0 0 20px;
	background:#FFF;
	border-left:5px solid #2BA6CB;
	overflow:hidden;
}
.logo {
	float:left;
}
.nav {
	float:right;
	margin:12px 0;
	list-style:none;
}
.nav-link {
	
}
.nav-link a {
	color:#2BA6CB;
	text-decoration:none;
}

/*
	Todd Motto Labs
	URL: www.toddmotto.com
*/

/*------------------------------------*\
    JS Event Handlers
\*------------------------------------*/

body {
	background:#34495E;
	color:#FFF;
	font-weight:900;
	font-size:15px;
}
.main {
	margin:0 auto;
	max-width:50vw;
}
/* Links */
#links {
	list-style:none;
}
.dynamic-link {
	cursor:pointer;
	background:#1ABC9C;
	padding:15px;
	margin:5px 0;
	border-radius:5px;
}
.dynamic-success {
	background:#16A085 url(../img/success.svg) no-repeat 98% center;
}
/* Generation form */
.generate {
	background:#ECEFF1;
	padding:25px;
	margin:25px 0;
	border-radius:5px;
  width: 55vw;
}
.generate-title {
	text-align:center;
	color:#34495E;
	font-size:22px;
}
.generate-input,
.generate-submit {
	text-align:center;
	font-size:16px;
	border:0;
	border-radius:5px;
	padding:15px 15px;
	margin:15px 0 0;
	width:100%;
}
.generate-input {
	background:#FFF;
	color:#34495E;
	outline:0;
	border:2px solid #FFF;
}
.generate-input:focus {
	border-color:#1ABC9C;
}
.generate-submit {
	cursor:pointer;
	color:#FFF;
	background:#1ABC9C;
}
              
            
!

JS

              
                (function(){
  // querySelector, jQuery style
  var $ = function (selector) {
    return document.querySelector(selector);
  };
  // Standardni dogadjaj "onsubmit":
  $('.generate').onsubmit = function() {
    // Grab the input value
    var unos = $('.generate-input').value;
    // Provera da li postoji unos
    if(!unos) {
      alert('Unesit neki tekst.');
    } else {
      var li = document.createElement('li');
      li.className = 'dynamic-link';
      li.innerHTML = unos;
      $('#links').appendChild(li);
      // Poruka pozivanje za izvršenje dinamickog dogadjaja:
      $('#message').innerHTML = 'Kliknite na napravljeni element da proverite da li je dinamički dodat event handler';
      // Dodavanje dinamičko dogadjaja na click
      li.onclick = dynamicEventCallback;
    }
    // Callback funkcija za dinamički dogadjaj
    function dynamicEventCallback() {
      this.innerHTML = 'Ovaj tekst je rezultat dinamički dodatog handler-a';
    }
    // Prevent the form submitting
    return false;
  }
})();
              
            
!
999px

Console