Unable to display selected value in jquery selectable
I want to display the selected item and only one item should be able to selected
i achieved the second but struggling for first,
Help Plz!!!!!!
- <!DOCTYPE html>
- <html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <meta charset="UTF-8">
- <title>jQuery single select</title>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
- <style type="text/css">
-
- #feedback { font-size: 1.4em; }
- #selectable .selecting { background: #FECA40; }
- #selectable .selected { background: #F39814; color: white; }
- #selectable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
- #selectable li { margin: 3px; padding: 0.4em; font-size: 1.4em; height: 18px; }
- </style>
- <body>
- <ul id="selectable">
- <li>Item 1</li>
- <li>Item 2</li>
- <li>Item 3</li>
- <li>Item 4</li>
- <li>Item 5</li>
- </ul>
- <p id="feedback">
- <span>You've selected:</span> <span id="select-result">none</span>.
- </p>
- <script>
- $("#selectable li").click(function() {
- $(this).addClass("selected").siblings().removeClass("selected");
- var result = $( "#select-result" ).empty();
- $( ".selected", this ).each(function() {
- var index = $( "#selectable li" ).index( this );
- result.append( " #" + ( 0 + 1 ) );
- });
-
- });
- </script>
- </body></html>