adsense

Wednesday, December 28, 2016

Jquery function to identify DIVs without text

You can use jQuery filter function to identify all the DIVs without text as displayed below.

$('.heading').filter(function(i,src){
    return $.trim($(src).text()).length == 0;
}).css('cursor', "pointer");

 

Cheers
Samitha

Tuesday, December 20, 2016

Detect window height using Javascript

JavaScript can be used to determine the height/width of the screen that is used to be viewing the page. i tried using jQuery height method but it seems some browsers (specifically in IE Compatibility modes) doesn't seem to calculate the height as expected.

Following function can be used to get the actual screen height and width, which is a cross browser compatible solution.

   function getWindowHeight(){
            return window.innerHeight ||
                   document.documentElement.clientHeight ||
                   document.body.clientHeight;
        }

function getWindowWidth() {
            return window.innerWidth ||
                   document.documentElement.clientWidth ||
                   document.body.clientWidth;
        }

Cheers
Samitha

Thursday, December 1, 2016

ASP .Net MVC wrap text in DisplayFor

If  the content displayed within a DisplayFor is too long you can wrap the text using following simple trick.

<div style="word-wrap:break-word;">
 @Html.DisplayFor(ModelItem => item.Text)
</div> 


cheers
Samitha