Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <td class="m1234Bottom" style="width:35%;">
- <span id="ABC123" class="Datetime">
- <div class="dateElement" id="ABC188c">
- <input name="ABC$123ccc"
- type="text">
- <a class="date"></a>
- <a style="display: none;" class="time"></a>
- </div>
- </span>
- </td>
- <td class="m1234Bottom" style="width:35%;">
- <span id="ABC123">
- 12/23/2012
- </span>
- </td>
- $("input[name*='123ccc']".each(function() {
- var outv= $(this).val();
- alert(outv);
- });
- var span = $('#ABC123');
- //check if span has input child
- if (span.find('input').length > 0) {
- //get value from input field
- var date = span.find('input').val();
- }
- else {
- //get text date from the span
- var date = span.text();
- }
- $(function() {
- $('#ABC123').find('input').length > 0 ? value = $('#ABC123').find('input').val() : value = $('#ABC123').text();
- console.log(value);
- });
- function retrieveValue()
- {
- // Retrieve the element (not guess yet)
- var spanOrInput = $("#ABCD123");
- // Try to guess if its an input or a span
- var type = spanOrInput.attr('type');
- if (typeof type == "undefined" || !type)
- return spanOrInput.val();
- else
- return spanOrInput.html();
- }
- <input type="hidden" id="hidtype" />
- $(function(){
- if ($('#hidtype').val() == '1') { //or what ever you use to set state
- // code here for that mode
- }
- else{
- // code for other type of mode
- }
- });
- if( $('#ABC123 input').length ) {
- //this means the input exists - handle from here
- }
Add Comment
Please, Sign In to add comment