jQuery javascript regex Replace br tag with \n

by in , , 0

var str = document.getElementById('mydiv').innerHTML;
document.getElementById('mytextarea').innerHTML = str.replace(/<br\s*[\/]?>/gi, "\n");
or using jQuery:
var str = $("#mydiv").html();
var regex = /<br\s*[\/]?>/gi;
$("#mydiv").html(str.replace(regex, "\n"));
edit: added i flag
edit2: you can use /<br[^>]*>/gi wich will match anything between the br and slash if you have for example <br />

Source:

jQuery javascript regex Replace <br> with \n

disable selected options by jQuery

by in , 0

This will disable/enable the options when you select/remove them, respectively.
$("#theSelect").change(function(){          
    var value = $(this).val();
    if (value === '') return;
    var theDiv = $(".is" + value);

    var option = $("option[value='" + value + "']", this);
    option.attr("disabled","disabled");

    theDiv.slideDown().removeClass("hidden");
    theDiv.find('a').data("option",option);
});


$("div a.remove").click(function () {     
    $(this).parent().slideUp(function() { $(this).addClass("hidden"); });
    $(this).data("option").removeAttr('disabled');
});
Source: 
jQuery - disable selected options

JavaScript QR Code Reader

by in , 0

I'm doing a bit of preliminary research on an upcoming project and I have a quick question that I figure I'll throw up here while I look elsewhere, in case anyone has any experience with this.
The question is simple: is it possible to read a QR code using JavaScript? Is there a remote service to which I can pass a bitmap object from a camera and do it that way? Are there currently any libraries that allow this?
The project is going to be deployed to various mobile devices and we'd like to try to use Appcelerator to make it work. I know Appcelerator does expose the Camera API on its host devices, but whatever we do with it has to be able to parse QR codes. Is this something that can be done?
Thanks in advance!

Read more »

How to Get all attributes of an element using jQuery

by in , 0

I am trying to go through an element and get all the attributes of that element to output them, for example an tag may have 3 or more attributes, unknown to me and I need to get the names and values of these attributes. I was thinking something along the lines of:

Read more »

10 Mobile Touch Javascript Frameworks

by in , 0

Mobile development is not an easy job for a developer who doesn’t know about the latest technologies, updates and trends that’s why mobile development is a stressful job. Major challenges a mobile developer faces are screen resolution, cross browser compatibility.
We know many of these issues have been solved as the mobile development industry is growing up. Now, we can see mobile websites with beautiful layouts are being developed. These mobile websites also have touch screen functionality that is developed with the help of different frameworks to work on tablets and smartphones.





Now, folks love to surf websites via their tablets, smartphones etc. So, having a mobile edition of your website is necessary. All this has been possible because of JavaScript, which has developed many frameworks to display our websites on mobile devices smoothly. So, below is the list of my Top 10 Mobile Touch JavaScript Frameworks.

1. pointer.js

pointer.js-
If you want unifying mouse and touch systems, pointer.js is the best tool. pointer.js reinforces pointer-like input models to work on various devices and browsers. You can do multi-touch drawing, gesture event logger and pointer event logger.

Read more »

6 jQuery Responsive Layout for mobile

by in 0

1. app-UI

TV Listings
app-UI may be helpful to mobile and web developers for developing interactive mobile or web applications using HTML and JavaScript. The animations are hardware accelerated and are rendered using CSS3 translate3d.

Read more »

Best 20 FlipBook responsive jQuery

by in , 0

1. WowBook, create ebooks with page flip

With WowBook, you can easily crate an online publication with two flipping effects. This plugin doesn’t need flash and supports all the major browsers. It also has zoom functionality, keyboard navigation and mousewheel navigation.

Read more »