Skip to content Skip to sidebar Skip to footer

Change `` Element Attributes From Objective-c

I'm trying to change the value of an element in a from null to checked. How would I do this from objective-C (iOS application)? Here's the relevant HT

Solution 1:

NSString *javaScript = @"document.getElementById('chk_Assignments').setAttribute('checked', 'checked');";

// Make the UIWebView method call
NSString *response = [webViewA stringByEvaluatingJavaScriptFromString:javaScript];
NSLog(@"javascript result: %@", response);

If HTML page got jQuery included, the javascript could be simplified:

NSString *javaScript = @"$('#chk_Assignments').attr('checked', 'checked');";
NSString *response = [webViewA stringByEvaluatingJavaScriptFromString:javaScript];
NSLog(@"javascript result: %@", response);

Post a Comment for "Change `` Element Attributes From Objective-c"